Skip to content

Instantly share code, notes, and snippets.

@fables-tales
Created July 22, 2010 14:10
Show Gist options
  • Save fables-tales/486001 to your computer and use it in GitHub Desktop.
Save fables-tales/486001 to your computer and use it in GitHub Desktop.
@values = internal global [8192 x i32] zeroinitializer
define i32 @main()
{
entry:
;create location and store zero to it
%location_ptr = alloca i32
store i32 0, i32* %location_ptr
%location = load i32* %location_ptr
;get the addr of the element at location
%firstelementaddr = getelementptr [8192 x i32]* @values, i32 0, i32 %location
%dereference = load i32* %firstelementaddr
%inc = add i32 10, %dereference
;store it back
store i32 %inc, i32* %firstelementaddr
;load it again
%ponies = load i32* %firstelementaddr
;a wild conditional appears
%cond = icmp eq i32 10, %ponies
;this is the block terminator
br i1 %cond, label %win, label %lose
;</conditional>
win:
ret i32 %ponies
lose:
ret i32 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment