mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
0d99339102
One of several parallel first steps to remove the target type of pointers, replacing them with a single opaque pointer type. This adds an explicit type parameter to the gep instruction so that when the first parameter becomes an opaque pointer type, the type to gep through is still available to the instructions. * This doesn't modify gep operators, only instructions (operators will be handled separately) * Textual IR changes only. Bitcode (including upgrade) and changing the in-memory representation will be in separate changes. * geps of vectors are transformed as: getelementptr <4 x float*> %x, ... ->getelementptr float, <4 x float*> %x, ... Then, once the opaque pointer type is introduced, this will ultimately look like: getelementptr float, <4 x ptr> %x with the unambiguous interpretation that it is a vector of pointers to float. * address spaces remain on the pointer, not the type: getelementptr float addrspace(1)* %x ->getelementptr float, float addrspace(1)* %x Then, eventually: getelementptr float, ptr addrspace(1) %x Importantly, the massive amount of test case churn has been automated by same crappy python code. I had to manually update a few test cases that wouldn't fit the script's model (r228970,r229196,r229197,r229198). The python script just massages stdin and writes the result to stdout, I then wrapped that in a shell script to handle replacing files, then using the usual find+xargs to migrate all the files. update.py: import fileinput import sys import re ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") def conv(match, line): if not match: return line line = match.groups()[0] if len(match.groups()[5]) == 0: line += match.groups()[2] line += match.groups()[3] line += ", " line += match.groups()[1] line += "\n" return line for line in sys.stdin: if line.find("getelementptr ") == line.find("getelementptr inbounds"): if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("): line = conv(re.match(ibrep, line), line) elif line.find("getelementptr ") != line.find("getelementptr ("): line = conv(re.match(normrep, line), line) sys.stdout.write(line) apply.sh: for name in "$@" do python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name" rm -f "$name.tmp" done The actual commands: From llvm/src: find test/ -name *.ll | xargs ./apply.sh From llvm/src/tools/clang: find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}" From llvm/src/tools/polly: find test/ -name *.ll | xargs ./apply.sh After that, check-all (with llvm, clang, clang-tools-extra, lld, compiler-rt, and polly all checked out). The extra 'rm' in the apply.sh script is due to a few files in clang's test suite using interesting unicode stuff that my python script was throwing exceptions on. None of those files needed to be migrated, so it seemed sufficient to ignore those cases. Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7636 llvm-svn: 230786
124 lines
3.8 KiB
LLVM
124 lines
3.8 KiB
LLVM
; RUN: llvm-dis < %s.bc| FileCheck %s
|
|
|
|
; constantsTest.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
|
|
; The test checks that LLVM does not misread binary float instructions of
|
|
; older bitcode files.
|
|
|
|
;global variable address
|
|
; CHECK: @X = global i32 0
|
|
@X = global i32 0
|
|
; CHECK: @Y = global i32 1
|
|
@Y = global i32 1
|
|
; CHECK: @Z = global [2 x i32*] [i32* @X, i32* @Y]
|
|
@Z = global [2 x i32*] [i32* @X, i32* @Y]
|
|
|
|
|
|
define void @SimpleConstants(i32 %x) {
|
|
entry:
|
|
; null
|
|
; CHECK: store i32 %x, i32* null
|
|
store i32 %x, i32* null
|
|
|
|
; boolean
|
|
; CHECK-NEXT: %res1 = fcmp true float 1.000000e+00, 1.000000e+00
|
|
%res1 = fcmp true float 1.0, 1.0
|
|
; CHECK-NEXT: %res2 = fcmp false float 1.000000e+00, 1.000000e+00
|
|
%res2 = fcmp false float 1.0, 1.0
|
|
|
|
;integer
|
|
; CHECK-NEXT: %res3 = add i32 0, 0
|
|
%res3 = add i32 0, 0
|
|
|
|
;float
|
|
; CHECK-NEXT: %res4 = fadd float 0.000000e+00, 0.000000e+00
|
|
%res4 = fadd float 0.0, 0.0
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @ComplexConstants(<2 x i32> %x){
|
|
entry:
|
|
;constant structure
|
|
; CHECK: %res1 = extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
|
|
%res1 = extractvalue {i32, float} {i32 1, float 2.0}, 0
|
|
|
|
;const array
|
|
; CHECK-NEXT: %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
|
|
%res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
|
|
|
|
;const vector
|
|
; CHECK-NEXT: %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
|
|
%res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
|
|
|
|
;zeroinitializer
|
|
; CHECK-NEXT: %res4 = add <2 x i32> %x, zeroinitializer
|
|
%res4 = add <2 x i32> %x, zeroinitializer
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @OtherConstants(i32 %x, i8* %Addr){
|
|
entry:
|
|
;undef
|
|
; CHECK: %res1 = add i32 %x, undef
|
|
%res1 = add i32 %x, undef
|
|
|
|
;poison
|
|
; CHECK-NEXT: %poison = sub nuw i32 0, 1
|
|
%poison = sub nuw i32 0, 1
|
|
|
|
;address of basic block
|
|
; CHECK-NEXT: %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
|
|
%res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
|
|
br label %Next
|
|
Next:
|
|
ret void
|
|
}
|
|
|
|
define void @OtherConstants2(){
|
|
entry:
|
|
; CHECK: trunc i32 1 to i8
|
|
trunc i32 1 to i8
|
|
; CHECK-NEXT: zext i8 1 to i32
|
|
zext i8 1 to i32
|
|
; CHECK-NEXT: sext i8 1 to i32
|
|
sext i8 1 to i32
|
|
; CHECK-NEXT: fptrunc double 1.000000e+00 to float
|
|
fptrunc double 1.0 to float
|
|
; CHECK-NEXT: fpext float 1.000000e+00 to double
|
|
fpext float 1.0 to double
|
|
; CHECK-NEXT: fptosi float 1.000000e+00 to i32
|
|
fptosi float 1.0 to i32
|
|
; CHECK-NEXT: uitofp i32 1 to float
|
|
uitofp i32 1 to float
|
|
; CHECK-NEXT: sitofp i32 -1 to float
|
|
sitofp i32 -1 to float
|
|
; CHECK-NEXT: ptrtoint i32* @X to i32
|
|
ptrtoint i32* @X to i32
|
|
; CHECK-NEXT: inttoptr i8 1 to i8*
|
|
inttoptr i8 1 to i8*
|
|
; CHECK-NEXT: bitcast i32 1 to <2 x i16>
|
|
bitcast i32 1 to <2 x i16>
|
|
; CHECK-NEXT: getelementptr i32, i32* @X, i32 0
|
|
getelementptr i32, i32* @X, i32 0
|
|
; CHECK-NEXT: getelementptr inbounds i32, i32* @X, i32 0
|
|
getelementptr inbounds i32, i32* @X, i32 0
|
|
; CHECK: select i1 true, i32 1, i32 0
|
|
select i1 true ,i32 1, i32 0
|
|
; CHECK-NEXT: icmp eq i32 1, 0
|
|
icmp eq i32 1, 0
|
|
; CHECK-NEXT: fcmp oeq float 1.000000e+00, 0.000000e+00
|
|
fcmp oeq float 1.0, 0.0
|
|
; CHECK-NEXT: extractelement <2 x i32> <i32 1, i32 1>, i32 1
|
|
extractelement <2 x i32> <i32 1, i32 1>, i32 1
|
|
; CHECK-NEXT: insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
|
|
insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
|
|
; CHECK-NEXT: shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
|
|
shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
|
|
; CHECK-NEXT: extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
|
|
extractvalue { i32, float } { i32 1, float 2.0 }, 0
|
|
; CHECK-NEXT: insertvalue { i32, float } { i32 1, float 2.000000e+00 }, i32 0, 0
|
|
insertvalue { i32, float } { i32 1, float 2.0 }, i32 0, 0
|
|
|
|
ret void
|
|
} |