mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
Add complement example
This commit is contained in:
6
examples/c/complement.c
Normal file
6
examples/c/complement.c
Normal file
@@ -0,0 +1,6 @@
|
||||
int nonce = 1; // For random input
|
||||
|
||||
int main() {
|
||||
int a = ~nonce;
|
||||
return a;
|
||||
}
|
||||
18
examples/ir0/complement.ir
Normal file
18
examples/ir0/complement.ir
Normal file
@@ -0,0 +1,18 @@
|
||||
var i32 @nonce = 1
|
||||
|
||||
fun i32 @main () {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:a
|
||||
|
||||
block b0:
|
||||
%b0:i0:i32 = load @nonce:i32*
|
||||
%b0:i1:i32 = xor %b0:i0:i32 -1:i32
|
||||
%b0:i2:unit = store %b0:i1:i32 %l0:i32*
|
||||
%b0:i3:i32 = load %l0:i32*
|
||||
ret %b0:i3:i32
|
||||
|
||||
block b1:
|
||||
ret 0:i32
|
||||
}
|
||||
15
examples/ir1/complement.ir
Normal file
15
examples/ir1/complement.ir
Normal file
@@ -0,0 +1,15 @@
|
||||
var i32 @nonce = 1
|
||||
|
||||
fun i32 @main () {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:a
|
||||
|
||||
block b0:
|
||||
%b0:i0:i32 = load @nonce:i32*
|
||||
%b0:i1:i32 = xor %b0:i0:i32 -1:i32
|
||||
%b0:i2:unit = store %b0:i1:i32 %l0:i32*
|
||||
%b0:i3:i32 = load %l0:i32*
|
||||
ret %b0:i3:i32
|
||||
}
|
||||
15
examples/ir2/complement.ir
Normal file
15
examples/ir2/complement.ir
Normal file
@@ -0,0 +1,15 @@
|
||||
var i32 @nonce = 1
|
||||
|
||||
fun i32 @main () {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:a
|
||||
|
||||
block b0:
|
||||
%b0:i0:i32 = load @nonce:i32*
|
||||
%b0:i1:i32 = xor %b0:i0:i32 -1:i32
|
||||
%b0:i2:unit = nop
|
||||
%b0:i3:unit = nop
|
||||
ret %b0:i1:i32
|
||||
}
|
||||
13
examples/ir3/complement.ir
Normal file
13
examples/ir3/complement.ir
Normal file
@@ -0,0 +1,13 @@
|
||||
var i32 @nonce = 1
|
||||
|
||||
fun i32 @main () {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
|
||||
block b0:
|
||||
%b0:i0:i32 = load @nonce:i32*
|
||||
%b0:i1:i32 = xor %b0:i0:i32 -1:i32
|
||||
ret %b0:i1:i32
|
||||
}
|
||||
13
examples/ir4/complement.ir
Normal file
13
examples/ir4/complement.ir
Normal file
@@ -0,0 +1,13 @@
|
||||
var i32 @nonce = 1
|
||||
|
||||
fun i32 @main () {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
|
||||
block b0:
|
||||
%b0:i0:i32 = load @nonce:i32*
|
||||
%b0:i1:i32 = xor %b0:i0:i32 -1:i32
|
||||
ret %b0:i1:i32
|
||||
}
|
||||
Reference in New Issue
Block a user