mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Adopting a uniform naming convention for constant constructors in bindings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -185,32 +185,29 @@ external dump_value : llvalue -> unit = "llvm_dump_value"
|
|||||||
|
|
||||||
(*--... Operations on constants of (mostly) any type .......................--*)
|
(*--... Operations on constants of (mostly) any type .......................--*)
|
||||||
external is_constant : llvalue -> bool = "llvm_is_constant"
|
external is_constant : llvalue -> bool = "llvm_is_constant"
|
||||||
external make_null : lltype -> llvalue = "LLVMGetNull"
|
external const_null : lltype -> llvalue = "LLVMConstNull"
|
||||||
external make_all_ones : (*int|vec*)lltype -> llvalue = "LLVMGetAllOnes"
|
external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
|
||||||
external make_undef : lltype -> llvalue = "LLVMGetUndef"
|
external undef : lltype -> llvalue = "LLVMGetUndef"
|
||||||
external is_null : llvalue -> bool = "llvm_is_null"
|
external is_null : llvalue -> bool = "llvm_is_null"
|
||||||
external is_undef : llvalue -> bool = "llvm_is_undef"
|
external is_undef : llvalue -> bool = "llvm_is_undef"
|
||||||
|
|
||||||
(*--... Operations on scalar constants .....................................--*)
|
(*--... Operations on scalar constants .....................................--*)
|
||||||
external make_int_constant : lltype -> int -> bool -> llvalue
|
external const_int : lltype -> int -> llvalue = "llvm_const_int"
|
||||||
= "llvm_make_int_constant"
|
external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
|
||||||
external make_int64_constant : lltype -> Int64.t -> bool -> llvalue
|
= "llvm_const_of_int64"
|
||||||
= "llvm_make_int64_constant"
|
external const_float : lltype -> float -> llvalue = "llvm_const_float"
|
||||||
external make_real_constant : lltype -> float -> llvalue
|
|
||||||
= "llvm_make_real_constant"
|
|
||||||
|
|
||||||
(*--... Operations on composite constants ..................................--*)
|
(*--... Operations on composite constants ..................................--*)
|
||||||
external make_string_constant : string -> bool -> llvalue
|
external const_string : string -> llvalue = "llvm_const_string"
|
||||||
= "llvm_make_string_constant"
|
external const_stringz : string -> llvalue = "llvm_const_stringz"
|
||||||
external make_array_constant : lltype -> llvalue array -> llvalue
|
external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
|
||||||
= "llvm_make_array_constant"
|
external const_struct : llvalue array -> llvalue = "llvm_const_struct"
|
||||||
external make_struct_constant : llvalue array -> bool -> llvalue
|
external const_packed_struct : llvalue array -> llvalue
|
||||||
= "llvm_make_struct_constant"
|
= "llvm_const_packed_struct"
|
||||||
external make_vector_constant : llvalue array -> llvalue
|
external const_vector : llvalue array -> llvalue = "llvm_const_vector"
|
||||||
= "llvm_make_vector_constant"
|
|
||||||
|
|
||||||
(*--... Constant expressions ...............................................--*)
|
(*--... Constant expressions ...............................................--*)
|
||||||
external sizeof : lltype -> llvalue = "LLVMSizeOf"
|
external size_of : lltype -> llvalue = "LLVMSizeOf"
|
||||||
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
||||||
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
||||||
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
||||||
|
@ -168,32 +168,29 @@ external dump_value : llvalue -> unit = "llvm_dump_value"
|
|||||||
|
|
||||||
(*--... Operations on constants of (mostly) any type .......................--*)
|
(*--... Operations on constants of (mostly) any type .......................--*)
|
||||||
external is_constant : llvalue -> bool = "llvm_is_constant"
|
external is_constant : llvalue -> bool = "llvm_is_constant"
|
||||||
external make_null : lltype -> llvalue = "LLVMGetNull"
|
external const_null : lltype -> llvalue = "LLVMConstNull"
|
||||||
external make_all_ones : (*int|vec*)lltype -> llvalue = "LLVMGetAllOnes"
|
external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
|
||||||
external make_undef : lltype -> llvalue = "LLVMGetUndef"
|
external undef : lltype -> llvalue = "LLVMGetUndef"
|
||||||
external is_null : llvalue -> bool = "llvm_is_null"
|
external is_null : llvalue -> bool = "llvm_is_null"
|
||||||
external is_undef : llvalue -> bool = "llvm_is_undef"
|
external is_undef : llvalue -> bool = "llvm_is_undef"
|
||||||
|
|
||||||
(*--... Operations on scalar constants .....................................--*)
|
(*--... Operations on scalar constants .....................................--*)
|
||||||
external make_int_constant : lltype -> int -> bool -> llvalue
|
external const_int : lltype -> int -> llvalue = "llvm_const_int"
|
||||||
= "llvm_make_int_constant"
|
external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
|
||||||
external make_int64_constant : lltype -> Int64.t -> bool -> llvalue
|
= "llvm_const_of_int64"
|
||||||
= "llvm_make_int64_constant"
|
external const_float : lltype -> float -> llvalue = "llvm_const_float"
|
||||||
external make_real_constant : lltype -> float -> llvalue
|
|
||||||
= "llvm_make_real_constant"
|
|
||||||
|
|
||||||
(*--... Operations on composite constants ..................................--*)
|
(*--... Operations on composite constants ..................................--*)
|
||||||
external make_string_constant : string -> bool -> llvalue
|
external const_string : string -> llvalue = "llvm_const_string"
|
||||||
= "llvm_make_string_constant"
|
external const_stringz : string -> llvalue = "llvm_const_stringz"
|
||||||
external make_array_constant : lltype -> llvalue array -> llvalue
|
external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
|
||||||
= "llvm_make_array_constant"
|
external const_struct : llvalue array -> llvalue = "llvm_const_struct"
|
||||||
external make_struct_constant : llvalue array -> bool -> llvalue
|
external const_packed_struct : llvalue array -> llvalue
|
||||||
= "llvm_make_struct_constant"
|
= "llvm_const_packed_struct"
|
||||||
external make_vector_constant : llvalue array -> llvalue
|
external const_vector : llvalue array -> llvalue = "llvm_const_vector"
|
||||||
= "llvm_make_vector_constant"
|
|
||||||
|
|
||||||
(*--... Constant expressions ...............................................--*)
|
(*--... Constant expressions ...............................................--*)
|
||||||
external sizeof : lltype -> llvalue = "LLVMSizeOf"
|
external size_of : lltype -> llvalue = "LLVMSizeOf"
|
||||||
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
||||||
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
||||||
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
||||||
|
@ -244,56 +244,57 @@ CAMLprim value llvm_is_undef(LLVMValueRef Val) {
|
|||||||
|
|
||||||
/*--... Operations on scalar constants .....................................--*/
|
/*--... Operations on scalar constants .....................................--*/
|
||||||
|
|
||||||
/* lltype -> int -> bool -> llvalue */
|
/* lltype -> int -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_int_constant(LLVMTypeRef IntTy, value N,
|
CAMLprim LLVMValueRef llvm_const_int(LLVMTypeRef IntTy, value N) {
|
||||||
value SExt) {
|
return LLVMConstInt(IntTy, (long long) Int_val(N), 1);
|
||||||
/* GCC warns if we use the ternary operator. */
|
|
||||||
unsigned long long N2;
|
|
||||||
if (Bool_val(SExt))
|
|
||||||
N2 = (value) Int_val(N);
|
|
||||||
else
|
|
||||||
N2 = (mlsize_t) Int_val(N);
|
|
||||||
|
|
||||||
return LLVMGetIntConstant(IntTy, N2, Bool_val(SExt));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lltype -> Int64.t -> bool -> llvalue */
|
/* lltype -> Int64.t -> bool -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_int64_constant(LLVMTypeRef IntTy, value N,
|
CAMLprim LLVMValueRef llvm_const_of_int64(LLVMTypeRef IntTy, value N,
|
||||||
value SExt) {
|
value SExt) {
|
||||||
return LLVMGetIntConstant(IntTy, Int64_val(N), Bool_val(SExt));
|
return LLVMConstInt(IntTy, Int64_val(N), Bool_val(SExt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lltype -> float -> llvalue */
|
/* lltype -> float -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_real_constant(LLVMTypeRef RealTy, value N) {
|
CAMLprim LLVMValueRef llvm_const_float(LLVMTypeRef RealTy, value N) {
|
||||||
return LLVMGetRealConstant(RealTy, Double_val(N));
|
return LLVMConstReal(RealTy, Double_val(N));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--... Operations on composite constants ..................................--*/
|
/*--... Operations on composite constants ..................................--*/
|
||||||
|
|
||||||
/* string -> bool -> llvalue */
|
/* string -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_string_constant(value Str, value NullTerminate) {
|
CAMLprim LLVMValueRef llvm_const_string(value Str, value NullTerminate) {
|
||||||
return LLVMGetStringConstant(String_val(Str), string_length(Str),
|
return LLVMConstString(String_val(Str), string_length(Str), 1);
|
||||||
Bool_val(NullTerminate) == 0);
|
}
|
||||||
|
|
||||||
|
/* string -> llvalue */
|
||||||
|
CAMLprim LLVMValueRef llvm_const_stringz(value Str, value NullTerminate) {
|
||||||
|
return LLVMConstString(String_val(Str), string_length(Str), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lltype -> llvalue array -> llvalue */
|
/* lltype -> llvalue array -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_array_constant(LLVMTypeRef ElementTy,
|
CAMLprim LLVMValueRef llvm_const_array(LLVMTypeRef ElementTy,
|
||||||
value ElementVals) {
|
value ElementVals) {
|
||||||
return LLVMGetArrayConstant(ElementTy, (LLVMValueRef*) Op_val(ElementVals),
|
return LLVMConstArray(ElementTy, (LLVMValueRef*) Op_val(ElementVals),
|
||||||
Wosize_val(ElementVals));
|
Wosize_val(ElementVals));
|
||||||
}
|
|
||||||
|
|
||||||
/* llvalue array -> bool -> llvalue */
|
|
||||||
CAMLprim LLVMValueRef llvm_make_struct_constant(value ElementVals,
|
|
||||||
value Packed) {
|
|
||||||
return LLVMGetStructConstant((LLVMValueRef *) Op_val(ElementVals),
|
|
||||||
Wosize_val(ElementVals), Bool_val(Packed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* llvalue array -> llvalue */
|
/* llvalue array -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_make_vector_constant(value ElementVals) {
|
CAMLprim LLVMValueRef llvm_const_struct(value ElementVals) {
|
||||||
return LLVMGetVectorConstant((LLVMValueRef*) Op_val(ElementVals),
|
return LLVMConstStruct((LLVMValueRef *) Op_val(ElementVals),
|
||||||
Wosize_val(ElementVals));
|
Wosize_val(ElementVals), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* llvalue array -> llvalue */
|
||||||
|
CAMLprim LLVMValueRef llvm_const_packed_struct(value ElementVals) {
|
||||||
|
return LLVMConstStruct((LLVMValueRef *) Op_val(ElementVals),
|
||||||
|
Wosize_val(ElementVals), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* llvalue array -> llvalue */
|
||||||
|
CAMLprim LLVMValueRef llvm_const_vector(value ElementVals) {
|
||||||
|
return LLVMConstVector((LLVMValueRef*) Op_val(ElementVals),
|
||||||
|
Wosize_val(ElementVals));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--... Constant expressions ...............................................--*/
|
/*--... Constant expressions ...............................................--*/
|
||||||
|
@ -228,27 +228,26 @@ void LLVMSetValueName(LLVMValueRef Val, const char *Name);
|
|||||||
void LLVMDumpValue(LLVMValueRef Val);
|
void LLVMDumpValue(LLVMValueRef Val);
|
||||||
|
|
||||||
/* Operations on constants of any type */
|
/* Operations on constants of any type */
|
||||||
LLVMValueRef LLVMGetNull(LLVMTypeRef Ty); /* all zeroes */
|
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
|
||||||
LLVMValueRef LLVMGetAllOnes(LLVMTypeRef Ty); /* only for int/vector */
|
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
|
||||||
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
|
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
|
||||||
int LLVMIsConstant(LLVMValueRef Val);
|
int LLVMIsConstant(LLVMValueRef Val);
|
||||||
int LLVMIsNull(LLVMValueRef Val);
|
int LLVMIsNull(LLVMValueRef Val);
|
||||||
int LLVMIsUndef(LLVMValueRef Val);
|
int LLVMIsUndef(LLVMValueRef Val);
|
||||||
|
|
||||||
/* Operations on scalar constants */
|
/* Operations on scalar constants */
|
||||||
LLVMValueRef LLVMGetIntConstant(LLVMTypeRef IntTy, unsigned long long N,
|
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
|
||||||
int SignExtend);
|
int SignExtend);
|
||||||
LLVMValueRef LLVMGetRealConstant(LLVMTypeRef RealTy, double N);
|
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
|
||||||
|
|
||||||
/* Operations on composite constants */
|
/* Operations on composite constants */
|
||||||
LLVMValueRef LLVMGetStringConstant(const char *Str, unsigned Length,
|
LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
|
||||||
int DontNullTerminate);
|
int DontNullTerminate);
|
||||||
LLVMValueRef LLVMGetArrayConstant(LLVMTypeRef ArrayTy,
|
LLVMValueRef LLVMConstArray(LLVMTypeRef ArrayTy,
|
||||||
LLVMValueRef *ConstantVals, unsigned Length);
|
LLVMValueRef *ConstantVals, unsigned Length);
|
||||||
LLVMValueRef LLVMGetStructConstant(LLVMValueRef *ConstantVals, unsigned Count,
|
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
|
||||||
int packed);
|
int packed);
|
||||||
LLVMValueRef LLVMGetVectorConstant(LLVMValueRef *ScalarConstantVals,
|
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
|
||||||
unsigned Size);
|
|
||||||
|
|
||||||
/* Constant expressions */
|
/* Constant expressions */
|
||||||
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
|
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
|
||||||
|
@ -200,11 +200,11 @@ void LLVMDumpValue(LLVMValueRef Val) {
|
|||||||
|
|
||||||
/*--.. Operations on constants of any type .................................--*/
|
/*--.. Operations on constants of any type .................................--*/
|
||||||
|
|
||||||
LLVMValueRef LLVMGetNull(LLVMTypeRef Ty) {
|
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty) {
|
||||||
return wrap(Constant::getNullValue(unwrap(Ty)));
|
return wrap(Constant::getNullValue(unwrap(Ty)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetAllOnes(LLVMTypeRef Ty) {
|
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty) {
|
||||||
return wrap(Constant::getAllOnesValue(unwrap(Ty)));
|
return wrap(Constant::getAllOnesValue(unwrap(Ty)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,40 +228,39 @@ int LLVMIsUndef(LLVMValueRef Val) {
|
|||||||
|
|
||||||
/*--.. Operations on scalar constants ......................................--*/
|
/*--.. Operations on scalar constants ......................................--*/
|
||||||
|
|
||||||
LLVMValueRef LLVMGetIntConstant(LLVMTypeRef IntTy, unsigned long long N,
|
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
|
||||||
int SignExtend) {
|
int SignExtend) {
|
||||||
return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
|
return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetRealConstant(LLVMTypeRef RealTy, double N) {
|
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N) {
|
||||||
return wrap(ConstantFP::get(unwrap(RealTy), APFloat(N)));
|
return wrap(ConstantFP::get(unwrap(RealTy), APFloat(N)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--.. Operations on composite constants ...................................--*/
|
/*--.. Operations on composite constants ...................................--*/
|
||||||
|
|
||||||
LLVMValueRef LLVMGetStringConstant(const char *Str, unsigned Length,
|
LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
|
||||||
int DontNullTerminate) {
|
int DontNullTerminate) {
|
||||||
/* Inverted the sense of AddNull because ', 0)' is a
|
/* Inverted the sense of AddNull because ', 0)' is a
|
||||||
better mnemonic for null termination than ', 1)'. */
|
better mnemonic for null termination than ', 1)'. */
|
||||||
return wrap(ConstantArray::get(std::string(Str, Length),
|
return wrap(ConstantArray::get(std::string(Str, Length),
|
||||||
DontNullTerminate == 0));
|
DontNullTerminate == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetArrayConstant(LLVMTypeRef ElementTy,
|
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
|
||||||
LLVMValueRef *ConstantVals, unsigned Length) {
|
LLVMValueRef *ConstantVals, unsigned Length) {
|
||||||
return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length),
|
return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length),
|
||||||
unwrap<Constant>(ConstantVals, Length),
|
unwrap<Constant>(ConstantVals, Length),
|
||||||
Length));
|
Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetStructConstant(LLVMValueRef *ConstantVals, unsigned Count,
|
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
|
||||||
int Packed) {
|
int Packed) {
|
||||||
return wrap(ConstantStruct::get(unwrap<Constant>(ConstantVals, Count),
|
return wrap(ConstantStruct::get(unwrap<Constant>(ConstantVals, Count),
|
||||||
Count, Packed != 0));
|
Count, Packed != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetVectorConstant(LLVMValueRef *ScalarConstantVals,
|
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
|
||||||
unsigned Size) {
|
|
||||||
return wrap(ConstantVector::get(unwrap<Constant>(ScalarConstantVals, Size),
|
return wrap(ConstantVector::get(unwrap<Constant>(ScalarConstantVals, Size),
|
||||||
Size));
|
Size));
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ let test_constants () =
|
|||||||
(* RUN: grep {Const01.*i32.*-1} < %t.ll
|
(* RUN: grep {Const01.*i32.*-1} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "int";
|
group "int";
|
||||||
let c = make_int_constant i32_type (-1) true in
|
let c = const_int i32_type (-1) in
|
||||||
ignore (define_global "Const01" c m);
|
ignore (define_global "Const01" c m);
|
||||||
insist (i32_type = type_of c);
|
insist (i32_type = type_of c);
|
||||||
insist (is_constant c);
|
insist (is_constant c);
|
||||||
@ -148,62 +148,62 @@ let test_constants () =
|
|||||||
(* RUN: grep {Const02.*i64.*-1} < %t.ll
|
(* RUN: grep {Const02.*i64.*-1} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "sext int";
|
group "sext int";
|
||||||
let c = make_int_constant i64_type (-1) true in
|
let c = const_int i64_type (-1) in
|
||||||
ignore (define_global "Const02" c m);
|
ignore (define_global "Const02" c m);
|
||||||
insist (i64_type = type_of c);
|
insist (i64_type = type_of c);
|
||||||
|
|
||||||
(* RUN: grep {Const03.*i64.*4294967295} < %t.ll
|
(* RUN: grep {Const03.*i64.*4294967295} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "zext int64";
|
group "zext int64";
|
||||||
let c = make_int64_constant i64_type (Int64.of_string "4294967295") false in
|
let c = const_of_int64 i64_type (Int64.of_string "4294967295") false in
|
||||||
ignore (define_global "Const03" c m);
|
ignore (define_global "Const03" c m);
|
||||||
insist (i64_type = type_of c);
|
insist (i64_type = type_of c);
|
||||||
|
|
||||||
(* RUN: grep {Const04.*"cruel\\\\00world"} < %t.ll
|
(* RUN: grep {Const04.*"cruel\\\\00world"} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "string";
|
group "string";
|
||||||
let c = make_string_constant "cruel\000world" false in
|
let c = const_string "cruel\000world" in
|
||||||
ignore (define_global "Const04" c m);
|
ignore (define_global "Const04" c m);
|
||||||
insist ((make_array_type i8_type 11) = type_of c);
|
insist ((make_array_type i8_type 11) = type_of c);
|
||||||
|
|
||||||
(* RUN: grep {Const05.*"hi\\\\00again\\\\00"} < %t.ll
|
(* RUN: grep {Const05.*"hi\\\\00again\\\\00"} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "string w/ null";
|
group "stringz";
|
||||||
let c = make_string_constant "hi\000again" true in
|
let c = const_stringz "hi\000again" in
|
||||||
ignore (define_global "Const05" c m);
|
ignore (define_global "Const05" c m);
|
||||||
insist ((make_array_type i8_type 9) = type_of c);
|
insist ((make_array_type i8_type 9) = type_of c);
|
||||||
|
|
||||||
(* RUN: grep {Const06.*3.1459} < %t.ll
|
(* RUN: grep {Const06.*3.1459} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "real";
|
group "real";
|
||||||
let c = make_real_constant double_type 3.1459 in
|
let c = const_float double_type 3.1459 in
|
||||||
ignore (define_global "Const06" c m);
|
ignore (define_global "Const06" c m);
|
||||||
insist (double_type = type_of c);
|
insist (double_type = type_of c);
|
||||||
|
|
||||||
let one = make_int_constant i16_type 1 true in
|
let one = const_int i16_type 1 in
|
||||||
let two = make_int_constant i16_type 2 true in
|
let two = const_int i16_type 2 in
|
||||||
let three = make_int_constant i32_type 3 true in
|
let three = const_int i32_type 3 in
|
||||||
let four = make_int_constant i32_type 4 true in
|
let four = const_int i32_type 4 in
|
||||||
|
|
||||||
(* RUN: grep {Const07.*\\\[ i32 3, i32 4 \\\]} < %t.ll
|
(* RUN: grep {Const07.*\\\[ i32 3, i32 4 \\\]} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "array";
|
group "array";
|
||||||
let c = make_array_constant i32_type [| three; four |] in
|
let c = const_array i32_type [| three; four |] in
|
||||||
ignore (define_global "Const07" c m);
|
ignore (define_global "Const07" c m);
|
||||||
insist ((make_array_type i32_type 2) = (type_of c));
|
insist ((make_array_type i32_type 2) = (type_of c));
|
||||||
|
|
||||||
(* RUN: grep {Const08.*< i16 1, i16 2.* >} < %t.ll
|
(* RUN: grep {Const08.*< i16 1, i16 2.* >} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "vector";
|
group "vector";
|
||||||
let c = make_vector_constant [| one; two; one; two;
|
let c = const_vector [| one; two; one; two;
|
||||||
one; two; one; two |] in
|
one; two; one; two |] in
|
||||||
ignore (define_global "Const08" c m);
|
ignore (define_global "Const08" c m);
|
||||||
insist ((make_vector_type i16_type 8) = (type_of c));
|
insist ((make_vector_type i16_type 8) = (type_of c));
|
||||||
|
|
||||||
(* RUN: grep {Const09.*\{ i16, i16, i32, i32 \} \{} < %t.ll
|
(* RUN: grep {Const09.*\{ i16, i16, i32, i32 \} \{} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "structure";
|
group "structure";
|
||||||
let c = make_struct_constant [| one; two; three; four |] false in
|
let c = const_struct [| one; two; three; four |] in
|
||||||
ignore (define_global "Const09" c m);
|
ignore (define_global "Const09" c m);
|
||||||
insist ((make_struct_type [| i16_type; i16_type; i32_type; i32_type |] false)
|
insist ((make_struct_type [| i16_type; i16_type; i32_type; i32_type |] false)
|
||||||
= (type_of c));
|
= (type_of c));
|
||||||
@ -211,20 +211,20 @@ let test_constants () =
|
|||||||
(* RUN: grep {Const10.*zeroinit} < %t.ll
|
(* RUN: grep {Const10.*zeroinit} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "null";
|
group "null";
|
||||||
let c = make_null (make_struct_type [| i1_type; i8_type;
|
let c = const_null (make_struct_type [| i1_type; i8_type;
|
||||||
i64_type; double_type |] true) in
|
i64_type; double_type |] true) in
|
||||||
ignore (define_global "Const10" c m);
|
ignore (define_global "Const10" c m);
|
||||||
|
|
||||||
(* RUN: grep {Const11.*-1} < %t.ll
|
(* RUN: grep {Const11.*-1} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "all ones";
|
group "all ones";
|
||||||
let c = make_all_ones i64_type in
|
let c = const_all_ones i64_type in
|
||||||
ignore (define_global "Const11" c m);
|
ignore (define_global "Const11" c m);
|
||||||
|
|
||||||
(* RUN: grep {Const12.*undef} < %t.ll
|
(* RUN: grep {Const12.*undef} < %t.ll
|
||||||
*)
|
*)
|
||||||
group "undef";
|
group "undef";
|
||||||
let c = make_undef i1_type in
|
let c = undef i1_type in
|
||||||
ignore (define_global "Const12" c m);
|
ignore (define_global "Const12" c m);
|
||||||
insist (i1_type = type_of c);
|
insist (i1_type = type_of c);
|
||||||
insist (is_undef c);
|
insist (is_undef c);
|
||||||
@ -248,9 +248,9 @@ let test_constants () =
|
|||||||
* RUN: grep {ConstFCmp.*fcmp} < %t.ll
|
* RUN: grep {ConstFCmp.*fcmp} < %t.ll
|
||||||
*)
|
*)
|
||||||
let void_ptr = make_pointer_type i8_type in
|
let void_ptr = make_pointer_type i8_type in
|
||||||
let five = make_int_constant i64_type 5 false in
|
let five = const_int i64_type 5 in
|
||||||
let ffive = const_uitofp five double_type in
|
let ffive = const_uitofp five double_type in
|
||||||
let foldbomb_gv = define_global "FoldBomb" (make_null i8_type) m in
|
let foldbomb_gv = define_global "FoldBomb" (const_null i8_type) m in
|
||||||
let foldbomb = const_ptrtoint foldbomb_gv i64_type in
|
let foldbomb = const_ptrtoint foldbomb_gv i64_type in
|
||||||
let ffoldbomb = const_uitofp foldbomb double_type in
|
let ffoldbomb = const_uitofp foldbomb double_type in
|
||||||
ignore (define_global "ConstNeg" (const_neg foldbomb) m);
|
ignore (define_global "ConstNeg" (const_neg foldbomb) m);
|
||||||
@ -296,8 +296,8 @@ let test_constants () =
|
|||||||
ignore (define_global "ConstFPToUI" (const_fptoui ffoldbomb i32_type) m);
|
ignore (define_global "ConstFPToUI" (const_fptoui ffoldbomb i32_type) m);
|
||||||
ignore (define_global "ConstFPToSI" (const_fptosi ffoldbomb i32_type) m);
|
ignore (define_global "ConstFPToSI" (const_fptosi ffoldbomb i32_type) m);
|
||||||
ignore (define_global "ConstPtrToInt" (const_ptrtoint
|
ignore (define_global "ConstPtrToInt" (const_ptrtoint
|
||||||
(const_gep (make_null (make_pointer_type i8_type))
|
(const_gep (const_null (make_pointer_type i8_type))
|
||||||
[| make_int_constant i32_type 1 false |])
|
[| const_int i32_type 1 |])
|
||||||
i32_type) m);
|
i32_type) m);
|
||||||
ignore (define_global "ConstIntToPtr" (const_inttoptr (const_add foldbomb five)
|
ignore (define_global "ConstIntToPtr" (const_inttoptr (const_add foldbomb five)
|
||||||
void_ptr) m);
|
void_ptr) m);
|
||||||
@ -311,23 +311,23 @@ let test_constants () =
|
|||||||
* RUN: grep {ConstInsertElement.*insertelement} < %t.ll
|
* RUN: grep {ConstInsertElement.*insertelement} < %t.ll
|
||||||
* RUN: grep {ConstShuffleVector.*shufflevector} < %t.ll
|
* RUN: grep {ConstShuffleVector.*shufflevector} < %t.ll
|
||||||
*)
|
*)
|
||||||
ignore (define_global "ConstSizeOf" (sizeof (make_pointer_type i8_type)) m);
|
ignore (define_global "ConstSizeOf" (size_of (make_pointer_type i8_type)) m);
|
||||||
ignore (define_global "ConstGEP" (const_gep foldbomb_gv [| five |]) m);
|
ignore (define_global "ConstGEP" (const_gep foldbomb_gv [| five |]) m);
|
||||||
ignore (define_global "ConstSelect" (const_select
|
ignore (define_global "ConstSelect" (const_select
|
||||||
(const_icmp Icmp_sle foldbomb five)
|
(const_icmp Icmp_sle foldbomb five)
|
||||||
(make_int_constant i8_type (-1) true)
|
(const_int i8_type (-1))
|
||||||
(make_int_constant i8_type 0 true)) m);
|
(const_int i8_type 0)) m);
|
||||||
let zero = make_int_constant i32_type 0 false in
|
let zero = const_int i32_type 0 in
|
||||||
let one = make_int_constant i32_type 1 false in
|
let one = const_int i32_type 1 in
|
||||||
ignore (define_global "ConstExtractElement" (const_extractelement
|
ignore (define_global "ConstExtractElement" (const_extractelement
|
||||||
(make_vector_constant [| zero; one; zero; one |])
|
(const_vector [| zero; one; zero; one |])
|
||||||
(const_trunc foldbomb i32_type)) m);
|
(const_trunc foldbomb i32_type)) m);
|
||||||
ignore (define_global "ConstInsertElement" (const_insertelement
|
ignore (define_global "ConstInsertElement" (const_insertelement
|
||||||
(make_vector_constant [| zero; one; zero; one |])
|
(const_vector [| zero; one; zero; one |])
|
||||||
zero (const_trunc foldbomb i32_type)) m);
|
zero (const_trunc foldbomb i32_type)) m);
|
||||||
ignore (define_global "ConstShuffleVector" (const_shufflevector
|
ignore (define_global "ConstShuffleVector" (const_shufflevector
|
||||||
(make_vector_constant [| zero; one |])
|
(const_vector [| zero; one |])
|
||||||
(make_vector_constant [| one; zero |])
|
(const_vector [| one; zero |])
|
||||||
(const_bitcast foldbomb (make_vector_type i32_type 2))) m)
|
(const_bitcast foldbomb (make_vector_type i32_type 2))) m)
|
||||||
|
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ let test_constants () =
|
|||||||
|
|
||||||
let test_global_values () =
|
let test_global_values () =
|
||||||
let (++) x f = f x; x in
|
let (++) x f = f x; x in
|
||||||
let zero32 = make_null i32_type in
|
let zero32 = const_null i32_type in
|
||||||
|
|
||||||
(* RUN: grep {GVal01} < %t.ll
|
(* RUN: grep {GVal01} < %t.ll
|
||||||
*)
|
*)
|
||||||
@ -378,7 +378,7 @@ let test_global_values () =
|
|||||||
|
|
||||||
let test_global_variables () =
|
let test_global_variables () =
|
||||||
let (++) x f = f x; x in
|
let (++) x f = f x; x in
|
||||||
let fourty_two32 = make_int_constant i32_type 42 false in
|
let fourty_two32 = const_int i32_type 42 in
|
||||||
|
|
||||||
(* RUN: grep {GVar01.*external} < %t.ll
|
(* RUN: grep {GVar01.*external} < %t.ll
|
||||||
*)
|
*)
|
||||||
@ -501,7 +501,7 @@ let test_basic_blocks () =
|
|||||||
let bb = entry_block fn in
|
let bb = entry_block fn in
|
||||||
insist (bb = block_of_value (value_of_block bb));
|
insist (bb = block_of_value (value_of_block bb));
|
||||||
insist (value_is_block (value_of_block bb));
|
insist (value_is_block (value_of_block bb));
|
||||||
insist (not (value_is_block (make_null i32_type)))
|
insist (not (value_is_block (const_null i32_type)))
|
||||||
|
|
||||||
|
|
||||||
(*===-- Builder -----------------------------------------------------------===*)
|
(*===-- Builder -----------------------------------------------------------===*)
|
||||||
@ -703,15 +703,15 @@ let test_builder () =
|
|||||||
let inst46 = build_icmp Icmp_eq p1 p2 "Inst46" atentry in
|
let inst46 = build_icmp Icmp_eq p1 p2 "Inst46" atentry in
|
||||||
ignore (build_select inst46 p1 p2 "Inst47" atentry);
|
ignore (build_select inst46 p1 p2 "Inst47" atentry);
|
||||||
ignore (build_va_arg
|
ignore (build_va_arg
|
||||||
(make_null (make_pointer_type (make_pointer_type i8_type)))
|
(const_null (make_pointer_type (make_pointer_type i8_type)))
|
||||||
i32_type "Inst48" atentry);
|
i32_type "Inst48" atentry);
|
||||||
|
|
||||||
(* Set up some vector vregs. *)
|
(* Set up some vector vregs. *)
|
||||||
let one = make_int_constant i32_type (-1) true in
|
let one = const_int i32_type (-1) in
|
||||||
let zero = make_int_constant i32_type 1 true in
|
let zero = const_int i32_type 1 in
|
||||||
let t1 = make_vector_constant [| one; zero; one; zero |] in
|
let t1 = const_vector [| one; zero; one; zero |] in
|
||||||
let t2 = make_vector_constant [| zero; one; zero; one |] in
|
let t2 = const_vector [| zero; one; zero; one |] in
|
||||||
let t3 = make_vector_constant [| one; one; zero; zero |] in
|
let t3 = const_vector [| one; one; zero; zero |] in
|
||||||
let vec1 = build_insertelement t1 p1 p2 "Vec1" atentry in
|
let vec1 = build_insertelement t1 p1 p2 "Vec1" atentry in
|
||||||
let vec2 = build_insertelement t2 p1 p2 "Vec2" atentry in
|
let vec2 = build_insertelement t2 p1 p2 "Vec2" atentry in
|
||||||
let vec3 = build_insertelement t3 p1 p2 "Vec3" atentry in
|
let vec3 = build_insertelement t3 p1 p2 "Vec3" atentry in
|
||||||
|
Reference in New Issue
Block a user