Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 17c1015

Browse files
committed
[MSP430] Generate EABI-compliant libcalls
Updates the MSP430 target to generate EABI-compatible libcall names. As a byproduct, adjusts the hardware multiplier options available in the MSP430 target, adds support for promotion of the ISD::MUL operation for 8-bit integers, and correctly marks R11 as used by call instructions. Patch by Andrew Wygle. Differential Revision: https://reviews.llvm.org/D32676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302820 91177308-0d34-0410-b5e6-96231b3b80d8 # Conflicts: # include/llvm/IR/CallingConv.h
1 parent cf85b5a commit 17c1015

File tree

11 files changed

+967
-40
lines changed

11 files changed

+967
-40
lines changed

include/llvm/IR/CallingConv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ namespace CallingConv {
196196
/// Register calling convention used for parameters transfer optimization
197197
X86_RegCall = 92,
198198

199+
/// Calling convention used for special MSP430 rtlib functions
200+
/// which have an "optimized" convention using additional registers.
201+
MSP430_BUILTIN = 94,
202+
199203
/// The highest possible calling convention ID. Must be some 2^k - 1.
200204
MaxID = 1023
201205
};

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4170,6 +4170,7 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
41704170
ReplacedNode(Node);
41714171
break;
41724172
}
4173+
case ISD::MUL:
41734174
case ISD::SDIV:
41744175
case ISD::SREM:
41754176
case ISD::UDIV:

lib/Target/MSP430/MSP430ISelLowering.cpp

Lines changed: 233 additions & 35 deletions
Large diffs are not rendered by default.

lib/Target/MSP430/MSP430InstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ let isCall = 1 in
209209
// a use to prevent stack-pointer assignments that appear immediately
210210
// before calls from potentially appearing dead. Uses for argument
211211
// registers are added manually.
212-
let Defs = [R12, R13, R14, R15, SR],
212+
let Defs = [R11, R12, R13, R14, R15, SR],
213213
Uses = [SP] in {
214214
def CALLi : II16i<0x0,
215215
(outs), (ins i16imm:$dst),

lib/Target/MSP430/MSP430RegisterInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ MSP430RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
4141
const Function* F = MF->getFunction();
4242
static const MCPhysReg CalleeSavedRegs[] = {
4343
MSP430::FP, MSP430::R5, MSP430::R6, MSP430::R7,
44-
MSP430::R8, MSP430::R9, MSP430::R10, MSP430::R11,
44+
MSP430::R8, MSP430::R9, MSP430::R10,
4545
0
4646
};
4747
static const MCPhysReg CalleeSavedRegsFP[] = {
4848
MSP430::R5, MSP430::R6, MSP430::R7,
49-
MSP430::R8, MSP430::R9, MSP430::R10, MSP430::R11,
49+
MSP430::R8, MSP430::R9, MSP430::R10,
5050
0
5151
};
5252
static const MCPhysReg CalleeSavedRegsIntr[] = {

test/CodeGen/MSP430/hwmult16.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: llc -O0 -mhwmult=16bit < %s | FileCheck %s
2+
3+
target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16"
4+
target triple = "msp430---elf"
5+
6+
@g_i32 = global i32 123, align 8
7+
@g_i64 = global i64 456, align 8
8+
@g_i16 = global i16 789, align 8
9+
10+
define i16 @mpyi() #0 {
11+
entry:
12+
; CHECK: mpyi:
13+
14+
; CHECK: call #__mspabi_mpyi_hw
15+
%0 = load volatile i16, i16* @g_i16, align 8
16+
%1 = mul i16 %0, %0
17+
18+
ret i16 %1
19+
}
20+
21+
define i32 @mpyli() #0 {
22+
entry:
23+
; CHECK: mpyli:
24+
25+
; CHECK: call #__mspabi_mpyl_hw
26+
%0 = load volatile i32, i32* @g_i32, align 8
27+
%1 = mul i32 %0, %0
28+
29+
ret i32 %1
30+
}
31+
32+
define i64 @mpylli() #0 {
33+
entry:
34+
; CHECK: mpylli:
35+
36+
; CHECK: call #__mspabi_mpyll_hw
37+
%0 = load volatile i64, i64* @g_i64, align 8
38+
%1 = mul i64 %0, %0
39+
40+
ret i64 %1
41+
}
42+
43+
attributes #0 = { nounwind }

test/CodeGen/MSP430/hwmult32.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: llc -O0 -mhwmult=32bit < %s | FileCheck %s
2+
3+
target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16"
4+
target triple = "msp430---elf"
5+
6+
@g_i32 = global i32 123, align 8
7+
@g_i64 = global i64 456, align 8
8+
@g_i16 = global i16 789, align 8
9+
10+
define i16 @mpyi() #0 {
11+
entry:
12+
; CHECK: mpyi:
13+
14+
; CHECK: call #__mspabi_mpyi_hw
15+
%0 = load volatile i16, i16* @g_i16, align 8
16+
%1 = mul i16 %0, %0
17+
18+
ret i16 %1
19+
}
20+
21+
define i32 @mpyli() #0 {
22+
entry:
23+
; CHECK: mpyli:
24+
25+
; CHECK: call #__mspabi_mpyl_hw32
26+
%0 = load volatile i32, i32* @g_i32, align 8
27+
%1 = mul i32 %0, %0
28+
29+
ret i32 %1
30+
}
31+
32+
define i64 @mpylli() #0 {
33+
entry:
34+
; CHECK: mpylli:
35+
36+
; CHECK: call #__mspabi_mpyll_hw32
37+
%0 = load volatile i64, i64* @g_i64, align 8
38+
%1 = mul i64 %0, %0
39+
40+
ret i64 %1
41+
}
42+
43+
attributes #0 = { nounwind }

test/CodeGen/MSP430/hwmultf5.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: llc -O0 -mhwmult=f5series < %s | FileCheck %s
2+
3+
target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16"
4+
target triple = "msp430---elf"
5+
6+
@g_i32 = global i32 123, align 8
7+
@g_i64 = global i64 456, align 8
8+
@g_i16 = global i16 789, align 8
9+
10+
define i16 @mpyi() #0 {
11+
entry:
12+
; CHECK: mpyi:
13+
14+
; CHECK: call #__mspabi_mpyi_f5hw
15+
%0 = load volatile i16, i16* @g_i16, align 8
16+
%1 = mul i16 %0, %0
17+
18+
ret i16 %1
19+
}
20+
21+
define i32 @mpyli() #0 {
22+
entry:
23+
; CHECK: mpyli:
24+
25+
; CHECK: call #__mspabi_mpyl_f5hw
26+
%0 = load volatile i32, i32* @g_i32, align 8
27+
%1 = mul i32 %0, %0
28+
29+
ret i32 %1
30+
}
31+
32+
define i64 @mpylli() #0 {
33+
entry:
34+
; CHECK: mpylli:
35+
36+
; CHECK: call #__mspabi_mpyll_f5hw
37+
%0 = load volatile i64, i64* @g_i64, align 8
38+
%1 = mul i64 %0, %0
39+
40+
ret i64 %1
41+
}
42+
43+
attributes #0 = { nounwind }

test/CodeGen/MSP430/jumptable.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ entry:
1212
store i16 %i, i16* %i.addr, align 2
1313
%0 = load i16, i16* %i.addr, align 2
1414
; CHECK: mov.w #2, r13
15-
; CHECK: call #__mulhi3hw_noint
15+
; CHECK: call #__mspabi_mpyi
1616
; CHECK: br .LJTI0_0(r12)
1717
switch i16 %0, label %sw.default [
1818
i16 0, label %sw.bb

0 commit comments

Comments
 (0)