@@ -133,8 +133,8 @@ abstract type ConstantDataSequential <: Constant end
133133# but cannot support that as explained above).
134134
135135# array interface
136- Base. eltype (cda:: ConstantDataSequential ) = llvmeltype ( cda)
137- Base. length (cda:: ConstantDataSequential ) = length (llvmtype (cda))
136+ Base. eltype (cda:: ConstantDataSequential ) = eltype ( value_type ( cda) )
137+ Base. length (cda:: ConstantDataSequential ) = length (value_type (cda))
138138Base. size (cda:: ConstantDataSequential ) = (length (cda),)
139139function Base. getindex (cda:: ConstantDataSequential , idx:: Integer )
140140 @boundscheck 1 <= idx <= length (cda) || throw (BoundsError (cda, idx))
@@ -191,7 +191,7 @@ register(ConstantAggregateZero, API.LLVMConstantAggregateZeroValueKind)
191191# array interface
192192# FIXME : can we reuse the ::ConstantArray functionality with ConstantAggregateZero values?
193193# probably works fine if we just get rid of the refcheck
194- Base. eltype (caz:: ConstantAggregateZero ) = llvmeltype ( caz)
194+ Base. eltype (caz:: ConstantAggregateZero ) = eltype ( value_type ( caz) )
195195Base. size (caz:: ConstantAggregateZero ) = (0 ,)
196196Base. length (caz:: ConstantAggregateZero ) = 0
197197Base. axes (caz:: ConstantAggregateZero ) = (Base. OneTo (0 ),)
@@ -215,15 +215,15 @@ register(ConstantArray, API.LLVMConstantArrayValueKind)
215215
216216# generic constructor taking an array of constants
217217function ConstantArray (typ:: LLVMType , data:: AbstractArray{T,N} = T[]) where {T<: Constant ,N}
218- @assert all (x-> x== typ, llvmtype .(data))
218+ @assert all (x-> x== typ, value_type .(data))
219219
220220 if N == 1
221221 # XXX : this can return a ConstDataArray (presumably as an optimization?)
222222 return Value (API. LLVMConstArray (typ, Array (data), length (data)))
223223 end
224224
225225 ca_vec = map (x-> ConstantArray (typ, x), eachslice (data, dims= 1 ))
226- ca_typ = llvmtype (first (ca_vec))
226+ ca_typ = value_type (first (ca_vec))
227227
228228 return ConstantArray (API. LLVMConstArray (ca_typ, ca_vec, length (ca_vec)))
229229end
@@ -252,10 +252,10 @@ function Base.collect(ca::ConstantArray)
252252end
253253
254254# array interface
255- Base. eltype (ca:: ConstantArray ) = llvmeltype (ca )
255+ Base. eltype (ca:: ConstantArray ) = eltype ( value_type (ca) )
256256function Base. size (ca:: ConstantArray )
257257 dims = Int[]
258- typ = llvmtype (ca)
258+ typ = value_type (ca)
259259 while typ isa ArrayType
260260 push! (dims, length (typ))
261261 typ = eltype (typ)
@@ -326,13 +326,13 @@ function ConstantStruct(value::T, name=String(nameof(T)); ctx::Context,
326326 ConstantStruct (constants; ctx, packed)
327327 elseif haskey (types (ctx), name)
328328 typ = types (ctx)[name]
329- if collect (elements (typ)) != llvmtype .(constants)
330- throw (ArgumentError (" Cannot create struct $name {$(join (llvmtype .(constants), " , " )) } as it is already defined in this context as {$(join (elements (typ), " , " )) }." ))
329+ if collect (elements (typ)) != value_type .(constants)
330+ throw (ArgumentError (" Cannot create struct $name {$(join (value_type .(constants), " , " )) } as it is already defined in this context as {$(join (elements (typ), " , " )) }." ))
331331 end
332332 ConstantStruct (typ, constants)
333333 else
334334 typ = StructType (name; ctx)
335- elements! (typ, llvmtype .(constants))
335+ elements! (typ, value_type .(constants))
336336 ConstantStruct (typ, constants)
337337 end
338338end
@@ -579,7 +579,7 @@ InlineAsm(typ::FunctionType, asm::String, constraints::String,
579579
580580abstract type GlobalValue <: Constant end
581581
582- export GlobalValue,
582+ export GlobalValue, global_value_type,
583583 isdeclaration,
584584 linkage, linkage!,
585585 section, section!,
@@ -590,6 +590,8 @@ export GlobalValue,
590590
591591parent (val:: GlobalValue ) = Module (API. LLVMGetGlobalParent (val))
592592
593+ global_value_type (val:: GlobalValue ) = LLVMType (API. LLVMGetGlobalValueType (val))
594+
593595isdeclaration (val:: GlobalValue ) = convert (Core. Bool, API. LLVMIsDeclaration (val))
594596
595597linkage (val:: GlobalValue ) = API. LLVMGetLinkage (val)
0 commit comments