aboutsummaryrefslogtreecommitdiffstats
path: root/test/Assembler/AutoUpgradeIntrinsics.ll
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2007-08-04 01:51:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2007-08-04 01:51:18 +0000
commit6994040a952e5fb27605eb3cf29ed86c4e59cf62 (patch)
treef1b3c2c54513244bf35e148ed628aa7c11923582 /test/Assembler/AutoUpgradeIntrinsics.ll
parent5dd75b4ca7e582f44da2f50362e8ab4c59972b5f (diff)
downloadexternal_llvm-6994040a952e5fb27605eb3cf29ed86c4e59cf62.zip
external_llvm-6994040a952e5fb27605eb3cf29ed86c4e59cf62.tar.gz
external_llvm-6994040a952e5fb27605eb3cf29ed86c4e59cf62.tar.bz2
This is the patch to provide clean intrinsic function overloading support in LLVM. It cleans up the intrinsic definitions and generally smooths the process for more complicated intrinsic writing. It will be used by the upcoming atomic intrinsics as well as vector and float intrinsics in the future.
This also changes the syntax for llvm.bswap, llvm.part.set, llvm.part.select, and llvm.ct* intrinsics. They are automatically upgraded by both the LLVM ASM reader and the bitcode reader. The test cases have been updated, with special tests added to ensure the automatic upgrading is supported. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Assembler/AutoUpgradeIntrinsics.ll')
-rw-r--r--test/Assembler/AutoUpgradeIntrinsics.ll52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/Assembler/AutoUpgradeIntrinsics.ll b/test/Assembler/AutoUpgradeIntrinsics.ll
new file mode 100644
index 0000000..fad3d4e
--- /dev/null
+++ b/test/Assembler/AutoUpgradeIntrinsics.ll
@@ -0,0 +1,52 @@
+; Tests to make sure intrinsics are automatically upgraded.
+; RUN: llvm-as < %s | llvm-dis | not grep {i32 @llvm\\.ct}
+; RUN: llvm-as < %s | llvm-dis | \
+; RUN: not grep {llvm\\.part\\.set\\.i\[0-9\]*\\.i\[0-9\]*\\.i\[0-9\]*}
+; RUN: llvm-as < %s | llvm-dis | \
+; RUN: not grep {llvm\\.part\\.select\\.i\[0-9\]*\\.i\[0-9\]*}
+; RUN: llvm-as < %s | llvm-dis | \
+; RUN: not grep {llvm\\.bswap\\.i\[0-9\]*\\.i\[0-9\]*}
+
+declare i32 @llvm.ctpop.i28(i28 %val)
+declare i32 @llvm.cttz.i29(i29 %val)
+declare i32 @llvm.ctlz.i30(i30 %val)
+
+define i32 @test_ct(i32 %A) {
+ %c1 = call i32 @llvm.ctpop.i28(i28 1234)
+ %c2 = call i32 @llvm.cttz.i29(i29 2345)
+ %c3 = call i32 @llvm.ctlz.i30(i30 3456)
+ %r1 = add i32 %c1, %c2
+ %r2 = add i32 %r1, %c3
+ ret i32 %r2
+}
+
+declare i32 @llvm.part.set.i32.i32.i32(i32 %x, i32 %rep, i32 %hi, i32 %lo)
+declare i16 @llvm.part.set.i16.i16.i16(i16 %x, i16 %rep, i32 %hi, i32 %lo)
+define i32 @test_part_set(i32 %A, i16 %B) {
+ %a = call i32 @llvm.part.set.i32.i32.i32(i32 %A, i32 27, i32 8, i32 0)
+ %b = call i16 @llvm.part.set.i16.i16.i16(i16 %B, i16 27, i32 8, i32 0)
+ %c = zext i16 %b to i32
+ %d = add i32 %a, %c
+ ret i32 %d
+}
+
+declare i32 @llvm.part.select.i32.i32(i32 %x, i32 %hi, i32 %lo)
+declare i16 @llvm.part.select.i16.i16(i16 %x, i32 %hi, i32 %lo)
+define i32 @test_part_select(i32 %A, i16 %B) {
+ %a = call i32 @llvm.part.select.i32.i32(i32 %A, i32 8, i32 0)
+ %b = call i16 @llvm.part.select.i16.i16(i16 %B, i32 8, i32 0)
+ %c = zext i16 %b to i32
+ %d = add i32 %a, %c
+ ret i32 %d
+}
+
+declare i32 @llvm.bswap.i32.i32(i32 %x)
+declare i16 @llvm.bswap.i16.i16(i16 %x)
+define i32 @test_bswap(i32 %A, i16 %B) {
+ %a = call i32 @llvm.bswap.i32.i32(i32 %A)
+ %b = call i16 @llvm.bswap.i16.i16(i16 %B)
+ %c = zext i16 %b to i32
+ %d = add i32 %a, %c
+ ret i32 %d
+}
+