Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: tests_lit/assembler/x86/immediate_encodings.ll

Issue 476323004: Start adding an integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: lit test to check encodings, swap complexi8 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests_lit/assembler/x86/immediate_encodings.ll
diff --git a/tests_lit/assembler/x86/immediate_encodings.ll b/tests_lit/assembler/x86/immediate_encodings.ll
new file mode 100644
index 0000000000000000000000000000000000000000..e639db9c8421e575e3f80f61baf1d431293f7776
--- /dev/null
+++ b/tests_lit/assembler/x86/immediate_encodings.ll
@@ -0,0 +1,62 @@
+; Tests various aspects of x86 immediate encoding. Some encodings are shorter.
+; For example, the encoding is shorter for 8-bit immediates or when using EAX.
+; This assumes that EAX is chosen as the first free register in O2 mode.
+
+; RUN: %llvm2ice -O2 --verbose none %s \
+; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \
+; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s
+; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN: | FileCheck --check-prefix=DUMP %s
+
+define internal i32 @testXorImm8(i32 %arg) {
+entry:
+ %arg_i8 = trunc i32 %arg to i8
+ %result_i8 = xor i8 %arg_i8, 127
+ %result = zext i8 %result_i8 to i32
+ ret i32 %result
+}
+; CHECK-LABEL: testXorImm8
+; CHECK: 34 7f xor al, 127
+
+define internal i32 @testXorImm8Neg(i32 %arg) {
+entry:
+ %arg_i8 = trunc i32 %arg to i8
+ %result_i8 = xor i8 %arg_i8, -56
+ %result = zext i8 %result_i8 to i32
+ ret i32 %result
+}
+; CHECK-LABEL: testXorImm8Neg
+; CHECK: 34 c8 xor al, -56
+
+define internal i32 @testXor32Imm8(i32 %arg) {
+entry:
+ %result = xor i32 %arg, 127
+ ret i32 %result
+}
+; CHECK-LABEL: testXor32Imm8
+; CHECK: 83 f0 7f xor eax, 127
+
+define internal i32 @testXor32ImmEax(i32 %arg) {
+entry:
+ %result = xor i32 %arg, 32767
+ ret i32 %result
+}
+; CHECK-LABEL: testXor32ImmEax
+; CHECK: 35 ff 7f 00 00 xor eax, 32767
+
+define internal i32 @testXor32ImmGeneral(i32 %arg, i32 %arg2, i32 %arg3) {
+entry:
+ %x = xor i32 %arg, 32767
+ %x2 = xor i32 %arg2, 32767
+ %x3 = xor i32 %arg3, 32767
+ %add1 = add i32 %x, %x2
+ %add2 = add i32 %add1, %x3
+ ret i32 %add2
+}
+; CHECK-LABEL: testXor32ImmGeneral
+; CHECK: 81 f1 ff 7f 00 00 xor e{{[^a]}}x, 32767
+
+; ERRORS-NOT: ICE translation error
+; DUMP-NOT: SZ

Powered by Google App Engine
This is Rietveld 408576698