Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/lib/values.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ unnamed_addr
unnamed_addr!
local_unnamed_addr
local_unnamed_addr!
alignment(::LLVM.GlobalValue)
alignment!(::LLVM.GlobalValue, ::Integer)
```

### Global variables
Expand All @@ -87,6 +85,8 @@ isconstant(::GlobalVariable)
constant!
isextinit
extinit!
alignment(::GlobalVariable)
alignment!(::GlobalVariable, ::Integer)
```

## Uses
Expand Down
2 changes: 1 addition & 1 deletion docs/src/man/values.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ couple of additional APIs:
- `linkage`/`linkage!`: get or set the linkage of the global value.
- `visibility`/`visibility!`: get or set the visibility of the global value.
- `section`/`section!`: get or set the section of the global value.
- `alignment`/`alignment!`: get or set the alignment of the global value.
- `dllstorage`/`dllstorage!`: get or set the DLL storage class of the global value.
- `unnamed_addr`/`unnamed_addr!`: get or set whether the global value has an unnamed address.
- `local_unnamed_addr`/`local_unnamed_addr!`: get or set whether the global value has a local unnamed address.
Expand All @@ -223,6 +222,7 @@ Global variables support additional APIs:
- `isconstant`/`isconstant!`: get or set whether the global variable is constant.
- `isextinit`/`isextinit!`: get or set whether the global variable is externally initialized.
- `erase!`: delete the global variable from its parent module, and delete the object.
- `alignment`/`alignment!`: get or set the alignment of the global variable.


## Uses
Expand Down
34 changes: 17 additions & 17 deletions src/core/value/constant.jl
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,7 @@ export GlobalValue, global_value_type,
visibility, visibility!,
dllstorage, dllstorage!,
unnamed_addr, unnamed_addr!,
local_unnamed_addr, local_unnamed_addr!,
alignment, alignment!
local_unnamed_addr, local_unnamed_addr!

"""
parent(val::LLVM.GlobalValue)
Expand Down Expand Up @@ -884,20 +883,6 @@ Set the local unnamed address flag of the global value.
"""
local_unnamed_addr!(val::GlobalValue, flag::Bool) = API.LLVMSetUnnamedAddress(val, flag ? API.LLVMLocalUnnamedAddr : API.LLVMNoUnnamedAddr)

"""
alignment(val::LLVM.GlobalValue)

Get the alignment of the global value.
"""
alignment(val::GlobalValue) = API.LLVMGetAlignment(val)

"""
alignment!(val::LLVM.GlobalValue, bytes::Integer)

Set the alignment of the global value.
"""
alignment!(val::GlobalValue, bytes::Integer) = API.LLVMSetAlignment(val, bytes)


## global variables

Expand All @@ -908,7 +893,8 @@ export GlobalVariable, erase!,
isthreadlocal, threadlocal!,
threadlocalmode, threadlocalmode!,
isconstant, constant!,
isextinit, extinit!
isextinit, extinit!,
alignment, alignment!

"""
GlobalVariable <: LLVM.GlobalObject
Expand Down Expand Up @@ -1020,3 +1006,17 @@ isextinit(gv::GlobalVariable) = API.LLVMIsExternallyInitialized(gv) |> Bool
Set the externally initialized flag of the global variable.
"""
extinit!(gv::GlobalVariable, bool) = API.LLVMSetExternallyInitialized(gv, bool)

"""
alignment(gv::GlobalVariable)

Get the alignment of the global variable.
"""
alignment(gv::GlobalVariable) = API.LLVMGetAlignment(gv)

"""
alignment!(gv::GlobalVariable, bytes::Integer)

Set the alignment of the global variable.
"""
alignment!(gv::GlobalVariable, bytes::Integer) = API.LLVMSetAlignment(gv, bytes)
8 changes: 4 additions & 4 deletions test/core_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,6 @@ end
@test !unnamed_addr(fn)
@test local_unnamed_addr(fn)

@test alignment(fn) == 0
alignment!(fn, 4)
@test alignment(fn) == 4

str = MDString("bar")
md = MDNode([str])
@test isempty(metadata(fn))
Expand Down Expand Up @@ -808,6 +804,10 @@ end
extinit!(gv, true)
@test isextinit(gv)

@test alignment(gv) == 0
alignment!(gv, 4)
@test alignment(gv) == 4

@test threadlocalmode(gv) == LLVM.API.LLVMGeneralDynamicTLSModel
threadlocalmode!(gv, LLVM.API.LLVMNotThreadLocal)
@test threadlocalmode(gv) == LLVM.API.LLVMNotThreadLocal
Expand Down
Loading