[llvm] [LoongArch][MC] Handle more PseudoLA* instructions with la-global-with-abs feature (PR #112858)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 18:04:48 PDT 2024
================
@@ -1023,14 +1021,42 @@ void LoongArchAsmParser::emitLoadAddressPcrelLarge(MCInst &Inst, SMLoc IDLoc,
void LoongArchAsmParser::emitLoadAddressGot(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out) {
// la.got $rd, sym
- // expands to:
- // pcalau12i $rd, %got_pc_hi20(sym)
- // ld.w/d $rd, $rd, %got_pc_lo12(sym)
MCRegister DestReg = Inst.getOperand(0).getReg();
const MCExpr *Symbol = Inst.getOperand(1).getExpr();
InstSeq Insts;
unsigned LD = is64Bit() ? LoongArch::LD_D : LoongArch::LD_W;
+ if (getSTI().hasFeature(LoongArch::LaGlobalWithAbs)) {
+ // with feature: +la-glabal-with-abs
+ // for 32bit:
+ // lu12i.w $rd, %got_hi20(sym)
+ // ori $rd, $rd, %got_lo12(sym)
+ // ld.w $rd, $rd, 0
+ //
+ // for 64bit:
+ // lu12i.w $rd, %got_hi20(sym)
+ // ori $rd, $rd, %got_lo12(sym)
+ // lu32i.d $rd, %got64_lo20(sym)
+ // lu52i.d $rd, $rd, %got64_hi12(sym)
+ // ld.d $rd, $rd, 0
----------------
wangleiat wrote:
This feature is only used for `macro instruction` expansion and is not related to the code model. It will only affect user-written assembly and will not impact the `LoongArch[PreRA]ExpandPseudo` pass in `codegen`.
https://github.com/llvm/llvm-project/pull/112858
More information about the llvm-commits
mailing list