Skip to content

Commit 85c0861

Browse files
committed
Support ConstantData(Vector|Array).
1 parent 2b37b27 commit 85c0861

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

src/core/value/constant.jl

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export null, isnull, all_ones, UndefValue, PointerNull
1+
export null, isnull, all_ones
22

33
null(typ::LLVMType) = Value(API.LLVMConstNull(typ))
44

@@ -18,27 +18,30 @@ end
1818
abstract type Instruction <: User end
1919

2020

21-
@checked struct PointerNull <: Constant
21+
## data
22+
23+
export ConstantData, PointerNull, UndefValue, ConstantInt, ConstantFP
24+
25+
abstract type ConstantData <: Constant end
26+
27+
28+
@checked struct PointerNull <: ConstantData
2229
ref::API.LLVMValueRef
2330
end
2431
register(PointerNull, API.LLVMConstantPointerNullValueKind)
2532

2633
PointerNull(typ::PointerType) = PointerNull(API.LLVMConstPointerNull(typ))
2734

2835

29-
@checked struct UndefValue <: Constant
36+
@checked struct UndefValue <: ConstantData
3037
ref::API.LLVMValueRef
3138
end
3239
register(UndefValue, API.LLVMUndefValueValueKind)
3340

3441
UndefValue(typ::LLVMType) = UndefValue(API.LLVMGetUndef(typ))
3542

3643

37-
## scalar
38-
39-
export ConstantInt, ConstantFP
40-
41-
@checked struct ConstantInt <: Constant
44+
@checked struct ConstantInt <: ConstantData
4245
ref::API.LLVMValueRef
4346
end
4447
register(ConstantInt, API.LLVMConstantIntValueKind)
@@ -82,7 +85,7 @@ Base.convert(::Type{T}, val::ConstantInt) where {T<:Signed} =
8285
Base.convert(::Type{Core.Bool}, val::ConstantInt) = convert(Int, val) != 0
8386

8487

85-
@checked struct ConstantFP <: Constant
88+
@checked struct ConstantFP <: ConstantData
8689
ref::API.LLVMValueRef
8790
end
8891
register(ConstantFP, API.LLVMConstantFPValueKind)
@@ -101,11 +104,28 @@ Base.convert(::Type{T}, val::ConstantFP) where {T<:AbstractFloat} =
101104
convert(T, API.LLVMConstRealGetDouble(val, Ref{API.LLVMBool}()))
102105

103106

104-
## aggregate zero
107+
# sequential
108+
109+
export ConstantDataSequential, ConstantDataArray, ConstantDataVector
110+
111+
abstract type ConstantDataSequential <: Constant end
112+
113+
@checked struct ConstantDataArray <: ConstantDataSequential
114+
ref::API.LLVMValueRef
115+
end
116+
register(ConstantDataArray, API.LLVMConstantDataArrayValueKind)
117+
118+
@checked struct ConstantDataVector <: ConstantDataSequential
119+
ref::API.LLVMValueRef
120+
end
121+
register(ConstantDataVector, API.LLVMConstantDataVectorValueKind)
122+
123+
124+
# aggregate zero
105125

106126
export ConstantAggregateZero
107127

108-
@checked struct ConstantAggregateZero <: Constant
128+
@checked struct ConstantAggregateZero <: ConstantData
109129
ref::API.LLVMValueRef
110130
end
111131
register(ConstantAggregateZero, API.LLVMConstantAggregateZeroValueKind)

0 commit comments

Comments
 (0)