[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c llvm-representation.c llvm-representation.h
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Thu Jul 7 10:32:57 PDT 2005
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.102 -> 1.103
llvm-representation.c updated: 1.18 -> 1.19
llvm-representation.h updated: 1.16 -> 1.17
---
Log message:
Convert llvm-gcc to using new style varargs.
This has been running for a couple weeks on alpha without problems.
---
Diffs of the changes: (+22 -49)
llvm-expand.c | 59 ++++++++++++++++----------------------------------
llvm-representation.c | 7 -----
llvm-representation.h | 5 ----
3 files changed, 22 insertions(+), 49 deletions(-)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.102 llvm-gcc/gcc/llvm-expand.c:1.103
--- llvm-gcc/gcc/llvm-expand.c:1.102 Sat Jun 18 16:11:19 2005
+++ llvm-gcc/gcc/llvm-expand.c Thu Jul 7 12:32:46 2005
@@ -265,7 +265,6 @@
static llvm_value *llvm_get_scalar_vararg(llvm_function *Fn,
llvm_value *VAListPtr,
llvm_type *ArgTy) {
- llvm_value *VAList = append_inst(Fn, create_load_inst("valist", VAListPtr,0));
llvm_value *Result;
llvm_instruction *VA;
llvm_type *ActualTy = ArgTy;
@@ -286,16 +285,9 @@
VA = llvm_instruction_new(ActualTy, "tmp", O_VAArg, 1);
- VA->Operands[0] = VAList;
+ VA->Operands[0] = VAListPtr;
Result = append_inst(Fn, VA);
- /* Update the valist */
- VA = llvm_instruction_new(VAList->Ty, "vanextlist", O_VANext, 1);
- VA->Operands[0] = VAList;
- VA->x.VANext.ArgTy = ActualTy;
- VAList = append_inst(Fn, VA);
-
- append_inst(Fn, create_store_inst(VAList, VAListPtr, 0));
return Result;
}
@@ -4390,11 +4382,12 @@
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
llvm_type *FnType = llvm_type_get_from_tree(TREE_TYPE(fndecl));
llvm_type *VAListTy = GET_FUNCTION_TYPE_ARGUMENT(FnType, 0);
- llvm_type *Ty = llvm_type_create_function(0, GET_POINTER_TYPE_ELEMENT(VAListTy));
- Ty = llvm_type_get_cannonical_function(Ty);
+ llvm_type *FnTy = llvm_type_create_function(1, VoidTy);
+ FnTy->Elements[1] = VAListTy;
+ llvm_type *Ty = llvm_type_get_cannonical_function(FnTy);
llvm_va_start_fn = CreateIntrinsicFnWithType("llvm.va_start", Ty);
}
-
+
if (TYPE_ARG_TYPES (fntype) == 0 ||
(TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype))) == void_type_node)) {
error("`va_start' used in function with fixed args");
@@ -4423,13 +4416,10 @@
*/
DestVal = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0);
VAListTy = GET_FUNCTION_TYPE_RETURN(GET_POINTER_TYPE_ELEMENT(G2V(llvm_va_start_fn)->Ty));
- Call = llvm_instruction_new(VAListTy, "begin", O_Call, 1);
+ Call = llvm_instruction_new(VoidTy, "", O_Call, 2);
Call->Operands[0] = G2V(llvm_va_start_fn);
+ Call->Operands[1] = DestVal;
append_inst(Fn, Call);
-
- DestVal = cast_if_type_not_equal(Fn, DestVal,
- llvm_type_get_pointer(VAListTy));
- append_inst(Fn, create_store_inst(D2V(Call), DestVal, 0));
}
static void llvm_expand_builtin_va_end(llvm_function *Fn, tree exp) {
@@ -4443,7 +4433,7 @@
llvm_type *VACopyTy = llvm_type_get_from_tree(TREE_TYPE(fndecl));
llvm_type *PtrVAListTy = GET_FUNCTION_TYPE_ARGUMENT(VACopyTy, 0);
llvm_type *FnTy = llvm_type_create_function(1, VoidTy);
- FnTy->Elements[1] = GET_POINTER_TYPE_ELEMENT(PtrVAListTy);
+ FnTy->Elements[1] = PtrVAListTy;
FnTy = llvm_type_get_cannonical_function(FnTy);
llvm_va_end_fn = CreateIntrinsicFnWithType("llvm.va_end", FnTy);
}
@@ -4451,11 +4441,10 @@
VAListType = GET_FUNCTION_TYPE_ARGUMENT(GET_POINTER_TYPE_ELEMENT(G2V(llvm_va_end_fn)->Ty), 0);
Arg = llvm_expand_expr(Fn, TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
- Arg = append_inst(Fn, create_load_inst("valist", Arg, 0));
Call = llvm_instruction_new(VoidTy, "", O_Call, 2);
Call->Operands[0] = G2V(llvm_va_end_fn);
- Call->Operands[1] = cast_if_type_not_equal(Fn, Arg, VAListType);
+ Call->Operands[1] = Arg;
append_inst(Fn, Call);
}
@@ -4466,29 +4455,21 @@
llvm_type *VAListType;
if (!llvm_va_copy_fn) {
llvm_type *VACopyTy = llvm_type_get_from_tree(TREE_TYPE(fndecl));
- llvm_type *VAListTy = GET_FUNCTION_TYPE_ARGUMENT(VACopyTy, 1);
- llvm_type *FnTy = llvm_type_create_function(1, VAListTy);
- FnTy->Elements[1] = VAListTy;
+ llvm_type *VAListTyPtr = GET_FUNCTION_TYPE_ARGUMENT(VACopyTy, 0);
+ llvm_type *FnTy = llvm_type_create_function(2, VoidTy);
+ FnTy->Elements[1] = VAListTyPtr;
+ FnTy->Elements[2] = VAListTyPtr;
FnTy = llvm_type_get_cannonical_function(FnTy);
llvm_va_copy_fn = CreateIntrinsicFnWithType("llvm.va_copy", FnTy);
}
- VAListType = GET_FUNCTION_TYPE_RETURN(GET_POINTER_TYPE_ELEMENT(G2V(llvm_va_copy_fn)->Ty));
-
- {
- tree SrcArg = TREE_VALUE(TREE_CHAIN(TREE_OPERAND(exp, 1)));
- llvm_instruction *I = llvm_instruction_new(VAListType, "tmp", O_Call, 2);
- llvm_value *DestAddr;
- I->Operands[0] = G2V(llvm_va_copy_fn);
- I->Operands[1] = llvm_expand_expr(Fn, SrcArg, 0);
- I->Operands[1] = cast_if_type_not_equal(Fn, I->Operands[1], VAListType);
- append_inst(Fn, I);
-
- DestAddr = llvm_expand_expr(Fn, TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
- DestAddr = cast_if_type_not_equal(Fn, DestAddr,
- llvm_type_get_pointer(VAListType));
- append_inst(Fn, create_store_inst(D2V(I), DestAddr, 0));
- }
+ tree SrcArg = TREE_VALUE(TREE_CHAIN(TREE_OPERAND(exp, 1)));
+ llvm_value *DestAddr = llvm_expand_expr(Fn, TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
+ llvm_instruction *I = llvm_instruction_new(VoidTy, "", O_Call, 3);
+ I->Operands[0] = G2V(llvm_va_copy_fn);
+ I->Operands[1] = DestAddr;
+ I->Operands[2] = llvm_expand_lvalue_expr(Fn, SrcArg, 0, 0);
+ append_inst(Fn, I);
}
static llvm_value *llvm_expand_builtin_alloca(llvm_function *Fn, tree arglist) {
Index: llvm-gcc/gcc/llvm-representation.c
diff -u llvm-gcc/gcc/llvm-representation.c:1.18 llvm-gcc/gcc/llvm-representation.c:1.19
--- llvm-gcc/gcc/llvm-representation.c:1.18 Sat Jun 18 16:11:20 2005
+++ llvm-gcc/gcc/llvm-representation.c Thu Jul 7 12:32:46 2005
@@ -405,8 +405,7 @@
case O_Shl: fprintf(F, "shl"); break;
case O_Shr: fprintf(F, "shr"); break;
case O_Select: fprintf(F, "select"); break;
- case O_VAArg: fprintf(F, "vaarg"); break;
- case O_VANext: fprintf(F, "vanext"); break;
+ case O_VAArg: fprintf(F, "va_arg"); break;
default: fprintf(F, "<unknown instruction opcode>"); break;
}
}
@@ -754,10 +753,6 @@
llvm_value_print_operand(Operand, 1, F);
fprintf(F, ", ");
llvm_type_print(D2V(I)->Ty, F);
- } else if (I->Opcode == O_VANext) {
- llvm_value_print_operand(Operand, 1, F);
- fprintf(F, ", ");
- llvm_type_print(I->x.VANext.ArgTy, F);
} else if (I->NumOperands) {
/* PrintAllTypes - Instructions who have operands of all the same type omit
* the type from all but the first operand. If the instruction has
Index: llvm-gcc/gcc/llvm-representation.h
diff -u llvm-gcc/gcc/llvm-representation.h:1.16 llvm-gcc/gcc/llvm-representation.h:1.17
--- llvm-gcc/gcc/llvm-representation.h:1.16 Sat Jun 18 16:11:20 2005
+++ llvm-gcc/gcc/llvm-representation.h Thu Jul 7 12:32:46 2005
@@ -168,7 +168,7 @@
O_And, O_Or, O_Xor,
O_SetEQ, O_SetNE, O_SetLE, O_SetGE, O_SetLT, O_SetGT,
O_Alloca, O_Malloc, O_Load, O_Store, O_GetElementPtr,
- O_PHINode, O_Cast, O_Call, O_Shl, O_Shr, O_Select, O_VAArg, O_VANext
+ O_PHINode, O_Cast, O_Call, O_Shl, O_Shr, O_Select, O_VAArg
} Opcode;
union {
@@ -178,9 +178,6 @@
struct { /* Valid for the O_Switch instruction */
llvm_switch_case *Cases;
} Switch;
- struct { /* Valid for the O_VANext instruction */
- struct llvm_type *ArgTy;
- } VANext;
} x;
unsigned NumOperands;
More information about the llvm-commits
mailing list