~mpu/qbe

Allow for symbols with @ characters

Details
Message ID
<CAAR=k6nE=poU0Eg83DMGYOD1n8tZJ5QaH0eS5SfYfxYXLd0zHg@mail.gmail.com>
DKIM signature
missing
Download raw message
I am trying to emulate the -fPIC flag from GCC/Clang, but it does not
seem like QBE is able to emit symbols with @ characters:

export function w $main() {
@start
  %x =l loadl $x@GOTPCREL
  %r =w loadw %x
  ret %r
}

The above code returns the following error:

qbe:x.ssa:3: , or end of line expected

I can change the problematic line to be:

  %r =l loadl $"x@GOTPCREL"

But now the following assembly (x86_64) is emitted:

  movq "x@GOTPCREL"(%rip), %rax

The issue now is that the quotes are causing the symbol to not be
resolved. The current work-around I have now is to use sed to remove
the quotes, but ideally QBE would somehow allow symbols with @
characters in them.

Some ideas I have for this:

* Unescape potential quotes when emitting (might break compatibility)
* Allow for escaping the @ symbol
* Allow for unescaped @ symbols in this context
* Add the ability to rename undefined symbols in data definitions
  similar to the asm() macro in C/C++

I'm unfamiliar with the QBE codebase, but I would be willing to work on
this if you find it worthwhile to implement this.
Reply to thread Export thread (mbox)