Skip to content

Commit

Permalink
CreateGEP/CreateInBoundsGEP
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Apr 20, 2024
1 parent 91a8927 commit 4615c39
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions z_llvmext.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ func CreateAlloca(b Builder, t Type) (v Value) {
return
}

func CreateGEP(b Builder, t Type, p Value, indices []Value) (v Value) {
ptr, nvals := llvmValueRefs(indices)
v.C = C.LLVMBuildGEP2(b.C, t.C, p.C, ptr, nvals, &emptyCStr[0])
return
}

func CreateInBoundsGEP(b Builder, t Type, p Value, indices []Value) (v Value) {
ptr, nvals := llvmValueRefs(indices)
v.C = C.LLVMBuildInBoundsGEP2(b.C, t.C, p.C, ptr, nvals, &emptyCStr[0])
return
}

func CreateStructGEP(b Builder, t Type, p Value, i int) (v Value) {
v.C = C.LLVMBuildStructGEP2(b.C, t.C, p.C, C.unsigned(i), &emptyCStr[0])
return
Expand Down

0 comments on commit 4615c39

Please sign in to comment.