Change some tests to be valid PNaCl IR (parameter type from i1 -> i32).
Change the i1 zeroext parameter to an explicit zext and
i32. Add an assert in lowerCall that the type is at least
32-bits.
I ended up putting the assert in lowerCall instead of
InstX8632Push, since technically there are quite a few
modes that push allows: 16-bit reg/mem (just not 8-bit
reg/mem) and 8/16/32 bit constants.
BUG=none
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/339933004
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 1e51047..dbfe60f 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -1281,6 +1281,8 @@
_mov(T, Arg);
_push(T);
} else {
+ // Otherwise PNaCl requires parameter types to be at least 32-bits.
+ assert(Arg->getType() == IceType_f32 || Arg->getType() == IceType_i32);
_push(Arg);
}
StackOffset += typeWidthInBytesOnStack(Arg->getType());
diff --git a/tests_lit/llvm2ice_tests/bool-opt.ll b/tests_lit/llvm2ice_tests/bool-opt.ll
index 1ccdeb6..40cc44b 100644
--- a/tests_lit/llvm2ice_tests/bool-opt.ll
+++ b/tests_lit/llvm2ice_tests/bool-opt.ll
@@ -9,11 +9,12 @@
define void @testBool(i32 %a, i32 %b) {
entry:
%cmp = icmp eq i32 %a, %b
- tail call void @use(i1 %cmp)
+ %cmp_ext = zext i1 %cmp to i32
+ tail call void @use(i32 %cmp_ext)
ret void
}
-declare void @use(i1 zeroext) #1
+declare void @use(i32)
; CHECK-NOT: ICE translation error
; ERRORS-NOT: ICE translation error
diff --git a/tests_lit/llvm2ice_tests/cmp-opt.ll b/tests_lit/llvm2ice_tests/cmp-opt.ll
index 342dfac..de3c18a 100644
--- a/tests_lit/llvm2ice_tests/cmp-opt.ll
+++ b/tests_lit/llvm2ice_tests/cmp-opt.ll
@@ -14,21 +14,23 @@
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
- tail call void @use(i1 %cmp)
+ %cmp_ext = zext i1 %cmp to i32
+ tail call void @use(i32 %cmp_ext)
br label %if.end
if.end: ; preds = %if.then, %entry
br i1 %cmp1, label %if.then5, label %if.end7
if.then5: ; preds = %if.end
- tail call void @use(i1 %cmp1)
+ %cmp1_ext = zext i1 %cmp1 to i32
+ tail call void @use(i32 %cmp1_ext)
br label %if.end7
if.end7: ; preds = %if.then5, %if.end
ret void
}
-declare void @use(i1 zeroext)
+declare void @use(i32)
; CHECK: .globl testBool
; Two bool computations
diff --git a/tests_lit/llvm2ice_tests/fp.pnacl.ll b/tests_lit/llvm2ice_tests/fp.pnacl.ll
index f8b7228..e73908e 100644
--- a/tests_lit/llvm2ice_tests/fp.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/fp.pnacl.ll
@@ -59,6 +59,18 @@
; CHECK: push 123
; CHECK: call ignoreFpArgsNoInline
+define internal i32 @passFp32ConstArg(float %a) {
+entry:
+ %call = call i32 @ignoreFp32ArgsNoInline(float %a, i32 123, float 2.0)
+ ret i32 %call
+}
+; CHECK: passFp32ConstArg:
+; CHECK: push dword
+; CHECK: push 123
+; CHECK: call ignoreFp32ArgsNoInline
+
+declare i32 @ignoreFp32ArgsNoInline(float, i32, float)
+
define internal float @returnFloatArg(float %a) {
entry:
ret float %a