llvm.org GIT mirror llvm / 379a087
Provide dynamic_stackalloc lowering for MSP430. This fixes PR4769 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80001 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
3 changed file(s) with 42 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
9494 setOperationAction(ISD::SELECT_CC, MVT::i8, Custom);
9595 setOperationAction(ISD::SELECT_CC, MVT::i16, Custom);
9696 setOperationAction(ISD::SIGN_EXTEND, MVT::i16, Custom);
97 setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i8, Expand);
98 setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i16, Expand);
9799
98100 setOperationAction(ISD::CTTZ, MVT::i8, Expand);
99101 setOperationAction(ISD::CTTZ, MVT::i16, Expand);
327327 // mergeSPUpdatesUp(MBB, MBBI, StackPtr, &NumBytes);
328328
329329 if (MFI->hasVarSizedObjects()) {
330 llvm_unreachable("Not implemented yet!");
330 BuildMI(MBB, MBBI, DL,
331 TII.get(MSP430::MOV16rr), MSP430::SPW).addReg(MSP430::FPW);
332 if (CSSize) {
333 MachineInstr *MI =
334 BuildMI(MBB, MBBI, DL,
335 TII.get(MSP430::SUB16ri), MSP430::SPW)
336 .addReg(MSP430::SPW).addImm(CSSize);
337 // The SRW implicit def is dead.
338 MI->getOperand(3).setIsDead();
339 }
331340 } else {
332341 // adjust stack pointer back: SPW += numbytes
333342 if (NumBytes) {
0 ; RUN: llvm-as < %s | llc
1 ; PR4769
2 target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"
3 target triple = "msp430-generic-generic"
4
5 define i16 @foo() nounwind readnone {
6 entry:
7 %result = alloca i16, align 1 ; [#uses=2]
8 volatile store i16 0, i16* %result
9 %tmp = volatile load i16* %result ; [#uses=1]
10 ret i16 %tmp
11 }
12
13 define i16 @main() nounwind {
14 entry:
15 br label %while.cond
16
17 while.cond: ; preds = %while.cond, %entry
18 %call = call i16 @bar() nounwind ; [#uses=1]
19 %tobool = icmp eq i16 %call, 0 ; [#uses=1]
20 br i1 %tobool, label %while.end, label %while.cond
21
22 while.end: ; preds = %while.cond
23 %result.i = alloca i16, align 1 ; [#uses=2]
24 volatile store i16 0, i16* %result.i
25 %tmp.i = volatile load i16* %result.i ; [#uses=0]
26 ret i16 0
27 }
28
29 declare i16 @bar()