[llvm-commits] [PATCH] Add support for ARMFastISel to select llvm.frameaddress

Chad Rosier mcrosier at apple.com
Tue May 29 09:09:25 PDT 2012


Jush,

+    unsigned LdrOpc = 0;
+    const TargetRegisterClass *RC = NULL;

I don't believe the compiler will warn if you don't initialize these.

+    unsigned DestReg = createResultReg(RC);
+
+    const ARMBaseRegisterInfo *RegInfo =
+          static_cast<const ARMBaseRegisterInfo*>(TM.getRegisterInfo());
+    unsigned FramePtr = RegInfo->getFrameRegister(*(FuncInfo.MF));
+    unsigned SrcReg = FramePtr;
+
+    // Recursively load frame address
+    // ldr r0 [fp]
+    // ldr r0 [r0]
+    // ldr r0 [r0]
+    // ...
+    unsigned Depth = cast<ConstantInt>(I.getOperand(0))->getZExtValue();
+    while (Depth--) {
+      AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
+                              TII.get(LdrOpc), DestReg)
+                      .addReg(SrcReg)
+                      .addImm(0));
+
+      SrcReg = DestReg;
+      DestReg = createResultReg(RC);
+    }

Could you restructure the loop so that it doesn't have an extra call to createResultReg()?  Basically, remove the createResultReg() from outside the loop and move the call inside the loop above the call to BuildMI().

 Chad


On May 28, 2012, at 1:42 AM, Jush Lu wrote:

> Hi,
> 
> This patch adds support for ARMFastISel to select
> llvm.frameaddress(i32), it passes all testcases and doesn't generate
> any warnings.
> 
> I have also tested this patch with several programs. Please help me
> review, thanks.
> 
> Jush
> <fast-isel-frameaddress.patch>




More information about the llvm-commits mailing list