about summary refs log tree commit diff homepage
path: root/test/Concrete/arith_test.ll
blob: f09cc7eb1fac3bf19c1c0704590888df03d3bedd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s

define void @"test_simple_arith"(i16 %i0, i16 %j0) {
  %t1 = add i16 %i0, %j0
  %t2 = sub i16 %i0, %j0
  %t3 = mul i16 %t1, %t2

  call void @print_i16(i16 %t3)

  ret void     
}

define void @"test_div_and_mod"(i16 %op1, i16 %op2) {
  %t1 = udiv i16 %op1, %op2
  %t2 = urem i16 %op1, %op2  
  %t3 = sdiv i16 %op1, %op2  
  %t4 = srem i16 %op1, %op2  

  call void @print_i16(i16 %t1)
  call void @print_i16(i16 %t2)
  call void @print_i16(i16 %t3)
  call void @print_i16(i16 %t4)

  ret void     
}
        
define void @test_cmp(i16 %op1, i16 %op2) {
  %t1 = icmp ule i16 %op1, %op2
  %t2 = icmp ult i16 %op1, %op2  
  %t3 = icmp uge i16 %op1, %op2  
  %t4 = icmp ugt i16 %op1, %op2  
  %t6 = icmp slt i16 %op1, %op2  
  %t5 = icmp sle i16 %op1, %op2
  %t7 = icmp sge i16 %op1, %op2  
  %t8 = icmp sgt i16 %op1, %op2  
  %t9 = icmp eq i16 %op1, %op2  
  %t10 = icmp ne i16 %op1, %op2  

  call void @print_i1(i1 %t1)
  call void @print_i1(i1 %t2)
  call void @print_i1(i1 %t3)
  call void @print_i1(i1 %t4)
  call void @print_i1(i1 %t5)
  call void @print_i1(i1 %t6)
  call void @print_i1(i1 %t7)
  call void @print_i1(i1 %t8)
  call void @print_i1(i1 %t9)
  call void @print_i1(i1 %t10)

  ret void
}

define i32 @main() {
    call void @test_simple_arith(i16 111, i16 100)

    call void @test_div_and_mod(i16 63331, i16 3123)
    call void @test_div_and_mod(i16 1000, i16 55444)
    call void @test_div_and_mod(i16 49012, i16 55444)
    call void @test_div_and_mod(i16 1000, i16 25)

    call void @test_cmp(i16 63331, i16 3123)
    call void @test_cmp(i16 1000, i16 55444)
    call void @test_cmp(i16 49012, i16 55444)
    call void @test_cmp(i16 1000, i16 25)
        
    ret i32 0
}

; defined in print_int.c
declare void @print_i1(i1)
declare void @print_i8(i8)
declare void @print_i16(i16)
declare void @print_i32(i32)
declare void @print_i64(i64)