[LLVMdev] Question about MCExpr and subclasses

Akira Hatanaka ahatanak at gmail.com
Mon Oct 17 18:03:04 PDT 2011

I guess that means I should be calling MCSymbolRefExpr::Create, like
ARM does, when I lower symbol operands. Is that right?

If MCSymbolRefExpr objects should be created, am I supposed to add
code to MCExpr::print (MCExpr.cpp:37) in order to print symbol
operands for MIps? I am hesitant to add my code here, since it looks a
little disorganized already.

Also, wtih MCSymbolRefExpr, how do I print symbols with offsets?
lw $7, %lo(f1.s1+4)($16)

I tried creating MCBinaryExpr with MCSymbolRefExpr and MCConstantExpr
operands, but I am getting something like this, which is not what I
lw $7, %lo(f1.s1)+4($16)

On Mon, Oct 17, 2011 at 5:30 PM, Jim Grosbach <grosbach at apple.com> wrote:
> That just means the ELF writer doesn't know yet how to deal with the target-specific data. It needs taught how to map them onto relocations and such.
> Do you really need to subclass MCTargetExpr? That's ordinarily only for operands that aren't representable via the normal MC stuff (for example, the ARM movw/movt relocations). You should be able represent normal symbol operands w/o needing a MCTargetExpr instance. The ARM or x86 targets may me useful reference points.
> -Jim
> On Oct 17, 2011, at 5:10 PM, Akira Hatanaka wrote:
>> I have a question about MCExpr and its subclasses defined in MCExpr.h.
>> I am trying to get Mips' direct object emission working.
>> Line 283 of MCElfStreamer.cpp reads like this:
>> 00283   case MCExpr::Target: llvm_unreachable("Can't handle target exprs yet!");
>> Does this mean that if I use a subclass of MCTargetExpr to lower
>> MachineOperands to MCOperands, it won't work?
>> Currently, symbol operands are lowered to MipsMCSymbolRefExpr (a
>> subclass of MCTargetExpr) objects.
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list