1*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as %s -o - | llvm-dis > %t1.ll 2*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll 3*9880d681SAndroid Build Coastguard Worker; RUN: diff %t1.ll %t2.ll 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; This testcase is for testing expressions constructed from 7*9880d681SAndroid Build Coastguard Worker; constant values, including constant pointers to globals. 8*9880d681SAndroid Build Coastguard Worker; 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker;;------------------------------- 11*9880d681SAndroid Build Coastguard Worker;; Test constant cast expressions 12*9880d681SAndroid Build Coastguard Worker;;------------------------------- 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker@0 = global i63 u0x00001 ; hexadecimal unsigned integer constants 15*9880d681SAndroid Build Coastguard Worker@1 = global i63 s0x012312 ; hexadecimal signed integer constants 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker@t2 = global i33* @t1 ;; Forward reference without cast 18*9880d681SAndroid Build Coastguard Worker@t3 = global i33* bitcast (i33* @t1 to i33*) ;; Forward reference with cast 19*9880d681SAndroid Build Coastguard Worker@t1 = global i33 4 ;; i32* @0 20*9880d681SAndroid Build Coastguard Worker@t4 = global i33** bitcast (i33** @t3 to i33**) ;; Cast of a previous cast 21*9880d681SAndroid Build Coastguard Worker@t5 = global i33** @t3 ;; Reference to a previous cast 22*9880d681SAndroid Build Coastguard Worker@t6 = global i33*** @t4 23*9880d681SAndroid Build Coastguard Worker@t7 = global float* inttoptr (i32 12345678 to float*) ;; Cast ordinary value to ptr 24*9880d681SAndroid Build Coastguard Worker@t9 = global i33 fptosi (float sitofp (i33 8 to float) to i33) ;; Nested cast expression 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker@2 = global i32* bitcast (float* @4 to i32*) ;; Forward numeric reference 28*9880d681SAndroid Build Coastguard Worker@3 = global float* @4 ;; Duplicate forward numeric reference 29*9880d681SAndroid Build Coastguard Worker@4 = global float 0.0 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker;;--------------------------------------------------- 33*9880d681SAndroid Build Coastguard Worker;; Test constant getelementpr expressions for arrays 34*9880d681SAndroid Build Coastguard Worker;;--------------------------------------------------- 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker@array = constant [2 x i33] [ i33 12, i33 52 ] 37*9880d681SAndroid Build Coastguard Worker@arrayPtr = global i33* getelementptr ([2 x i33], [2 x i33]* @array, i64 0, i64 0) ;; i33* &@array[0][0] 38*9880d681SAndroid Build Coastguard Worker@arrayPtr5 = global i33** getelementptr (i33*, i33** @arrayPtr, i64 5) ;; i33* &@arrayPtr[5] 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Worker@somestr = constant [11x i8] c"hello world" 41*9880d681SAndroid Build Coastguard Worker@char5 = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 0, i64 5) 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Worker;; cast of getelementptr 44*9880d681SAndroid Build Coastguard Worker@char8a = global i33* bitcast (i8* getelementptr([11x i8], [11x i8]* @somestr, i64 0, i64 8) to i33*) 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker;; getelementptr containing casts 47*9880d681SAndroid Build Coastguard Worker@char8b = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 sext (i8 0 to i64), i64 sext (i8 8 to i64)) 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Worker;;------------------------------------------------------- 50*9880d681SAndroid Build Coastguard Worker;; TODO: Test constant getelementpr expressions for structures 51*9880d681SAndroid Build Coastguard Worker;;------------------------------------------------------- 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker%SType = type { i33 , {float, {i8} }, i64 } ;; struct containing struct 54*9880d681SAndroid Build Coastguard Worker%SAType = type { i33 , {[2x float], i64} } ;; struct containing array 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker@S1 = global %SType* null ;; Global initialized to NULL 57*9880d681SAndroid Build Coastguard Worker@S2c = constant %SType { i33 1, {float,{i8}} {float 2.0, {i8} {i8 3}}, i64 4} 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker@S3c = constant %SAType { i33 1, {[2x float], i64} {[2x float] [float 2.0, float 3.0], i64 4} } 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker@S1ptr = global %SType** @S1 ;; Ref. to global S1 62*9880d681SAndroid Build Coastguard Worker@S2 = global %SType* @S2c ;; Ref. to constant S2 63*9880d681SAndroid Build Coastguard Worker@S3 = global %SAType* @S3c ;; Ref. to constant S3 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker ;; Pointer to float (**@S1).1.0 66*9880d681SAndroid Build Coastguard Worker@S1fld1a = global float* getelementptr (%SType, %SType* @S2c, i64 0, i32 1, i32 0) 67*9880d681SAndroid Build Coastguard Worker ;; Another ptr to the same! 68*9880d681SAndroid Build Coastguard Worker@S1fld1b = global float* getelementptr (%SType, %SType* @S2c, i64 0, i32 1, i32 0) 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker@S1fld1bptr = global float** @S1fld1b ;; Ref. to previous pointer 71*9880d681SAndroid Build Coastguard Worker 72*9880d681SAndroid Build Coastguard Worker ;; Pointer to i8 (**@S2).1.1.0 73*9880d681SAndroid Build Coastguard Worker@S2fld3 = global i8* getelementptr (%SType, %SType* @S2c, i64 0, i32 1, i32 1, i32 0) 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Worker ;; Pointer to float (**@S2).1.0[0] 76*9880d681SAndroid Build Coastguard Worker;@S3fld3 = global float* getelementptr (%SAType*, %SAType** @S3, i64 0, i64 0, i32 1, i32 0, i64 0) 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Worker;;--------------------------------------------------------- 79*9880d681SAndroid Build Coastguard Worker;; TODO: Test constant expressions for unary and binary operators 80*9880d681SAndroid Build Coastguard Worker;;--------------------------------------------------------- 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Worker;;--------------------------------------------------- 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker 85