MIPS 32bit code generation

Hi,

In order to emit “la $4,ADDR” instead of lui followed by addiu to load the data address, could you advise what is proper way to revise td files in the MIPS target?

Thanks,

Why?

-eric

Hi,

for our micro-architecture research, we are using simplescalar 3.0 32bit mips simulator, which comes with binutils 1.5.2, and the ld fails at “lui” (bfd error). However, the ld is happy with “la” (assembler macro) and simulator correctly simulates.

Do you want to replace

lui $2, %hi(g1)
addiu $2, $2, %lo(g1)

with this?
la $2, g1

If that is the case, you can add this pattern.

def op_la : Operand<i32>;

def LA :
  FI<0x09, (outs CPURegs:$dst), (ins op_la:$addr0, op_la:$addr1),
     "la $dst, $addr0", [(set CPURegs:$dst,
                         (add (MipsHi tglobaladdr:$addr0), (MipsLo
tglobaladdr:$addr1)))], IIAlu>;

Note that you still need to find a way to print "g1" instead of "%hi(g1)".

Fixing the simulator is the more appropriate solution.

Hi,

I noticed one class in MipsInstrFormats.td:L46 → Class MipsPseudo. I wonder whether I can use this. If does, I wonder what would be the right way to use. Thanks,

I reiterate. You should fix the simulator. It is broken. The compiler is not. Fix what's broken.

-Jim

I don’t think I ever said that the MIPS target is broken. I am simply trying to branch out one additional llc target for SimpleScalar PISA architecture.

I don't think I ever said that the MIPS target is broken. I am simply trying to branch out one additional llc target for SimpleScalar PISA architecture.

for our micro-architecture research, we are using simplescalar 3.0 32bit mips simulator, which comes with binutils 1.5.2, and the ld fails at "lui" (bfd error). However, the ld is happy with "la" (assembler macro) and simulator correctly simulates.

That almost certainly means the simulator binutils are broken.

As was mentioned back in July when you last asked about this, you really should be updating to a newer binutils. If you don't, you will continue to encounter problems until you do. binutils 1.5.2 is ancient, buggy, and completely unsupported.

-Jim