[llvm] r176647 - Hexagon: Handle i8, i16 and i1 Var Args.
Jyotsna Verma
jverma at codeaurora.org
Thu Mar 7 12:28:34 PST 2013
Author: jverma
Date: Thu Mar 7 14:28:34 2013
New Revision: 176647
URL: http://llvm.org/viewvc/llvm-project?rev=176647&view=rev
Log:
Hexagon: Handle i8, i16 and i1 Var Args.
Added:
llvm/trunk/test/CodeGen/Hexagon/i16_VarArg.ll
llvm/trunk/test/CodeGen/Hexagon/i1_VarArg.ll
llvm/trunk/test/CodeGen/Hexagon/i8_VarArg.ll
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp?rev=176647&r1=176646&r2=176647&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp Thu Mar 7 14:28:34 2013
@@ -103,6 +103,16 @@ CC_Hexagon_VarArg (unsigned ValNo, MVT V
State.addLoc(CCValAssign::getMem(ValNo, ValVT, ofst, LocVT, LocInfo));
return false;
}
+ if (LocVT == MVT::i1 || LocVT == MVT::i8 || LocVT == MVT::i16) {
+ LocVT = MVT::i32;
+ ValVT = MVT::i32;
+ if (ArgFlags.isSExt())
+ LocInfo = CCValAssign::SExt;
+ else if (ArgFlags.isZExt())
+ LocInfo = CCValAssign::ZExt;
+ else
+ LocInfo = CCValAssign::AExt;
+ }
if (LocVT == MVT::i32 || LocVT == MVT::f32) {
ofst = State.AllocateStack(4, 4);
State.addLoc(CCValAssign::getMem(ValNo, ValVT, ofst, LocVT, LocInfo));
Added: llvm/trunk/test/CodeGen/Hexagon/i16_VarArg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/i16_VarArg.ll?rev=176647&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/i16_VarArg.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/i16_VarArg.ll Thu Mar 7 14:28:34 2013
@@ -0,0 +1,40 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+; CHECK: call __hexagon_{{[A-Z_a-z0-9]+}}
+
+ at a_str = internal constant [8 x i8] c"a = %f\0A\00"
+ at b_str = internal constant [8 x i8] c"b = %f\0A\00"
+ at add_str = internal constant [12 x i8] c"a + b = %f\0A\00"
+ at sub_str = internal constant [12 x i8] c"a - b = %f\0A\00"
+ at mul_str = internal constant [12 x i8] c"a * b = %f\0A\00"
+ at div_str = internal constant [12 x i8] c"b / a = %f\0A\00"
+ at rem_str = internal constant [13 x i8] c"b %% a = %f\0A\00"
+ at lt_str = internal constant [12 x i8] c"a < b = %d\0A\00"
+ at le_str = internal constant [13 x i8] c"a <= b = %d\0A\00"
+ at gt_str = internal constant [12 x i8] c"a > b = %d\0A\00"
+ at ge_str = internal constant [13 x i8] c"a >= b = %d\0A\00"
+ at eq_str = internal constant [13 x i8] c"a == b = %d\0A\00"
+ at ne_str = internal constant [13 x i8] c"a != b = %d\0A\00"
+ at A = global double 2.000000e+00
+ at B = global double 5.000000e+00
+
+declare i32 @printf(i8*, ...)
+
+define i32 @main() {
+ %a = load double* @A
+ %b = load double* @B
+ %lt_r = fcmp olt double %a, %b
+ %le_r = fcmp ole double %a, %b
+ %gt_r = fcmp ogt double %a, %b
+ %ge_r = fcmp oge double %a, %b
+ %eq_r = fcmp oeq double %a, %b
+ %ne_r = fcmp une double %a, %b
+ %val1 = zext i1 %lt_r to i16
+ %lt_s = getelementptr [12 x i8]* @lt_str, i64 0, i64 0
+ %le_s = getelementptr [13 x i8]* @le_str, i64 0, i64 0
+ %gt_s = getelementptr [12 x i8]* @gt_str, i64 0, i64 0
+ %ge_s = getelementptr [13 x i8]* @ge_str, i64 0, i64 0
+ %eq_s = getelementptr [13 x i8]* @eq_str, i64 0, i64 0
+ %ne_s = getelementptr [13 x i8]* @ne_str, i64 0, i64 0
+ call i32 (i8*, ...)* @printf( i8* %lt_s, i16 %val1 )
+ ret i32 0
+}
\ No newline at end of file
Added: llvm/trunk/test/CodeGen/Hexagon/i1_VarArg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/i1_VarArg.ll?rev=176647&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/i1_VarArg.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/i1_VarArg.ll Thu Mar 7 14:28:34 2013
@@ -0,0 +1,44 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+; CHECK: call __hexagon_{{[_A-Za-z0-9]+}}
+
+ at a_str = internal constant [8 x i8] c"a = %f\0A\00"
+ at b_str = internal constant [8 x i8] c"b = %f\0A\00"
+ at add_str = internal constant [12 x i8] c"a + b = %f\0A\00"
+ at sub_str = internal constant [12 x i8] c"a - b = %f\0A\00"
+ at mul_str = internal constant [12 x i8] c"a * b = %f\0A\00"
+ at div_str = internal constant [12 x i8] c"b / a = %f\0A\00"
+ at rem_str = internal constant [13 x i8] c"b %% a = %f\0A\00"
+ at lt_str = internal constant [12 x i8] c"a < b = %d\0A\00"
+ at le_str = internal constant [13 x i8] c"a <= b = %d\0A\00"
+ at gt_str = internal constant [12 x i8] c"a > b = %d\0A\00"
+ at ge_str = internal constant [13 x i8] c"a >= b = %d\0A\00"
+ at eq_str = internal constant [13 x i8] c"a == b = %d\0A\00"
+ at ne_str = internal constant [13 x i8] c"a != b = %d\0A\00"
+ at A = global double 2.000000e+00
+ at B = global double 5.000000e+00
+
+declare i32 @printf(i8*, ...)
+
+define i32 @main() {
+ %a = load double* @A
+ %b = load double* @B
+ %lt_r = fcmp olt double %a, %b
+ %le_r = fcmp ole double %a, %b
+ %gt_r = fcmp ogt double %a, %b
+ %ge_r = fcmp oge double %a, %b
+ %eq_r = fcmp oeq double %a, %b
+ %ne_r = fcmp une double %a, %b
+ %lt_s = getelementptr [12 x i8]* @lt_str, i64 0, i64 0
+ %le_s = getelementptr [13 x i8]* @le_str, i64 0, i64 0
+ %gt_s = getelementptr [12 x i8]* @gt_str, i64 0, i64 0
+ %ge_s = getelementptr [13 x i8]* @ge_str, i64 0, i64 0
+ %eq_s = getelementptr [13 x i8]* @eq_str, i64 0, i64 0
+ %ne_s = getelementptr [13 x i8]* @ne_str, i64 0, i64 0
+ call i32 (i8*, ...)* @printf( i8* %lt_s, i1 %lt_r )
+ call i32 (i8*, ...)* @printf( i8* %le_s, i1 %le_r )
+ call i32 (i8*, ...)* @printf( i8* %gt_s, i1 %gt_r )
+ call i32 (i8*, ...)* @printf( i8* %ge_s, i1 %ge_r )
+ call i32 (i8*, ...)* @printf( i8* %eq_s, i1 %eq_r )
+ call i32 (i8*, ...)* @printf( i8* %ne_s, i1 %ne_r )
+ ret i32 0
+}
\ No newline at end of file
Added: llvm/trunk/test/CodeGen/Hexagon/i8_VarArg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/i8_VarArg.ll?rev=176647&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/i8_VarArg.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/i8_VarArg.ll Thu Mar 7 14:28:34 2013
@@ -0,0 +1,40 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+; CHECK: call __hexagon_{{[A-Z_a-z0-9]+}}
+
+ at a_str = internal constant [8 x i8] c"a = %f\0A\00"
+ at b_str = internal constant [8 x i8] c"b = %f\0A\00"
+ at add_str = internal constant [12 x i8] c"a + b = %f\0A\00"
+ at sub_str = internal constant [12 x i8] c"a - b = %f\0A\00"
+ at mul_str = internal constant [12 x i8] c"a * b = %f\0A\00"
+ at div_str = internal constant [12 x i8] c"b / a = %f\0A\00"
+ at rem_str = internal constant [13 x i8] c"b %% a = %f\0A\00"
+ at lt_str = internal constant [12 x i8] c"a < b = %d\0A\00"
+ at le_str = internal constant [13 x i8] c"a <= b = %d\0A\00"
+ at gt_str = internal constant [12 x i8] c"a > b = %d\0A\00"
+ at ge_str = internal constant [13 x i8] c"a >= b = %d\0A\00"
+ at eq_str = internal constant [13 x i8] c"a == b = %d\0A\00"
+ at ne_str = internal constant [13 x i8] c"a != b = %d\0A\00"
+ at A = global double 2.000000e+00
+ at B = global double 5.000000e+00
+
+declare i32 @printf(i8*, ...)
+
+define i32 @main() {
+ %a = load double* @A
+ %b = load double* @B
+ %lt_r = fcmp olt double %a, %b
+ %le_r = fcmp ole double %a, %b
+ %gt_r = fcmp ogt double %a, %b
+ %ge_r = fcmp oge double %a, %b
+ %eq_r = fcmp oeq double %a, %b
+ %ne_r = fcmp une double %a, %b
+ %val1 = zext i1 %lt_r to i8
+ %lt_s = getelementptr [12 x i8]* @lt_str, i64 0, i64 0
+ %le_s = getelementptr [13 x i8]* @le_str, i64 0, i64 0
+ %gt_s = getelementptr [12 x i8]* @gt_str, i64 0, i64 0
+ %ge_s = getelementptr [13 x i8]* @ge_str, i64 0, i64 0
+ %eq_s = getelementptr [13 x i8]* @eq_str, i64 0, i64 0
+ %ne_s = getelementptr [13 x i8]* @ne_str, i64 0, i64 0
+ call i32 (i8*, ...)* @printf( i8* %lt_s, i8 %val1 )
+ ret i32 0
+}
\ No newline at end of file
More information about the llvm-commits
mailing list