OSDN Git Service

Handle stores of global address as stores of immediates. Instead of:
authorChris Lattner <sabre@nondot.org>
Thu, 21 Apr 2005 19:11:03 +0000 (19:11 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 21 Apr 2005 19:11:03 +0000 (19:11 +0000)
test1:
        movl $N, %eax
        movl %eax, G
        ret

emit:

test1:
        movl $N, G
        ret

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21407 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelSimple.cpp

index 6c37b70..b7e1520 100644 (file)
@@ -1620,6 +1620,9 @@ void X86ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
         } else if (Args[i].Val && isa<ConstantPointerNull>(Args[i].Val)) {
           addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
                        X86::ESP, ArgOffset).addImm(0);
+        } else if (Args[i].Val && isa<GlobalValue>(Args[i].Val)) {
+          addRegOffset(BuildMI(BB, X86::MOV32mi, 5), X86::ESP, ArgOffset)
+            .addGlobalAddress(cast<GlobalValue>(Args[i].Val));
         } else {
           ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
           addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
@@ -3311,6 +3314,8 @@ void X86ISel::visitStoreInst(StoreInst &I) {
     }
   } else if (isa<ConstantPointerNull>(I.getOperand(0))) {
     addFullAddress(BuildMI(BB, X86::MOV32mi, 5), AM).addImm(0);
+  } else if (GlobalValue *GV = dyn_cast<GlobalValue>(I.getOperand(0))) {
+    addFullAddress(BuildMI(BB, X86::MOV32mi, 5), AM).addGlobalAddress(GV);
   } else if (ConstantBool *CB = dyn_cast<ConstantBool>(I.getOperand(0))) {
     addFullAddress(BuildMI(BB, X86::MOV8mi, 5), AM).addImm(CB->getValue());
   } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0))) {