summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>2015-04-17 17:29:58 +0000
committerVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>2015-04-17 17:29:58 +0000
commit816ea84e7a191301a008d89071b674f1fd218c55 (patch)
treebcec523432790b17141a5c82ee349e5a882f6251 /llvm
parent2be05eef3181cecc83011e07abc35a410c3b9bbb (diff)
downloadbcm5719-llvm-816ea84e7a191301a008d89071b674f1fd218c55.tar.gz
bcm5719-llvm-816ea84e7a191301a008d89071b674f1fd218c55.zip
[mips][FastISel] Implement FastMaterializeAlloca in Mips fast-isel.
Summary: Implement the method FastMaterializeAlloca in Mips fast-isel Based on a patch by Reed Kotler. Test Plan: Passes test-suite at O0/O2 for mips32 r1/r2 fastalloca.ll Reviewers: dsanders, rkotler Subscribers: rfuhler, llvm-commits Differential Revision: http://reviews.llvm.org/D6742 llvm-svn: 235213
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/Mips/MipsFastISel.cpp20
-rw-r--r--llvm/test/CodeGen/Mips/Fast-ISel/fastalloca.ll32
2 files changed, 52 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MipsFastISel.cpp b/llvm/lib/Target/Mips/MipsFastISel.cpp
index 03d5ea2bab7..4b60606eb25 100644
--- a/llvm/lib/Target/Mips/MipsFastISel.cpp
+++ b/llvm/lib/Target/Mips/MipsFastISel.cpp
@@ -187,6 +187,7 @@ public:
UnsupportedFPMode = Subtarget->isFP64bit();
}
+ unsigned fastMaterializeAlloca(const AllocaInst *AI) override;
unsigned fastMaterializeConstant(const Constant *C) override;
bool fastSelectInstruction(const Instruction *I) override;
@@ -253,6 +254,25 @@ unsigned MipsFastISel::emitLogicalOp(unsigned ISDOpc, MVT RetVT,
return ResultReg;
}
+unsigned MipsFastISel::fastMaterializeAlloca(const AllocaInst *AI) {
+ assert(TLI.getValueType(AI->getType(), true) == MVT::i32 &&
+ "Alloca should always return a pointer.");
+
+ DenseMap<const AllocaInst *, int>::iterator SI =
+ FuncInfo.StaticAllocaMap.find(AI);
+
+ if (SI != FuncInfo.StaticAllocaMap.end()) {
+ unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
+ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Mips::LEA_ADDiu),
+ ResultReg)
+ .addFrameIndex(SI->second)
+ .addImm(0);
+ return ResultReg;
+ }
+
+ return 0;
+}
+
unsigned MipsFastISel::materializeInt(const Constant *C, MVT VT) {
if (VT != MVT::i32 && VT != MVT::i16 && VT != MVT::i8 && VT != MVT::i1)
return 0;
diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/fastalloca.ll b/llvm/test/CodeGen/Mips/Fast-ISel/fastalloca.ll
new file mode 100644
index 00000000000..b4a9f1ce7ab
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/fastalloca.ll
@@ -0,0 +1,32 @@
+; RUN: llc -march=mipsel -relocation-model=pic -O0 -mips-fast-isel -fast-isel-abort=1 -mcpu=mips32r2 \
+; RUN: < %s | FileCheck %s
+
+%struct.x = type { i32 }
+
+@i = common global i32 0, align 4
+
+define i32 @foobar(i32 signext %x) {
+entry:
+; CHECK-LABEL: foobar:
+ %retval = alloca i32, align 4
+ %x.addr = alloca i32, align 4
+ %a = alloca %struct.x, align 4
+ %c = alloca %struct.x*, align 4
+ store i32 %x, i32* %x.addr, align 4
+ %x1 = getelementptr inbounds %struct.x, %struct.x* %a, i32 0, i32 0
+ %0 = load i32, i32* %x.addr, align 4
+ store i32 %0, i32* %x1, align 4
+ store %struct.x* %a, %struct.x** %c, align 4
+ %1 = load %struct.x*, %struct.x** %c, align 4
+ %x2 = getelementptr inbounds %struct.x, %struct.x* %1, i32 0, i32 0
+ %2 = load i32, i32* %x2, align 4
+ store i32 %2, i32* @i, align 4
+ %3 = load i32, i32* %retval
+; CHECK-DAG: lw $[[I_ADDR:[0-9]+]], %got(i)($[[REG_GP:[0-9]+]])
+; CHECK-DAG: addiu $[[A_ADDR:[0-9]+]], $sp, 8
+; CHECK-DAG: sw $[[A_ADDR]], [[A_ADDR_FI:[0-9]+]]($sp)
+; CHECK-DAG: lw $[[A_ADDR2:[0-9]+]], [[A_ADDR_FI]]($sp)
+; CHECK-DAG: lw $[[A_X:[0-9]+]], 0($[[A_ADDR2]])
+; CHECK-DAG: sw $[[A_X]], 0($[[I_ADDR]])
+ ret i32 %3
+}
OpenPOWER on IntegriCloud