Skip to content

Commit 246368b

Browse files
committed
Add CallBase to avoid misuse of APIs.
1 parent e5a6981 commit 246368b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/core/instructions.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,24 @@ end
131131

132132
## call sites and invocations
133133

134-
# TODO: restrict these to CallBase instructions
134+
# TODO: add this to the actual type hierarchy
135+
const CallBase = Union{CallBrInst, CallInst, InvokeInst}
135136

136137
export callconv, callconv!,
137138
istailcall, tailcall!,
138139
called_value, arguments,
139140
OperandBundleUse, OperandBundleDef, operand_bundles
140141

141-
callconv(inst::Instruction) = API.LLVMGetInstructionCallConv(inst)
142-
callconv!(inst::Instruction, cc) =
142+
callconv(inst::CallBase) = API.LLVMGetInstructionCallConv(inst)
143+
callconv!(inst::CallBase, cc) =
143144
API.LLVMSetInstructionCallConv(inst, cc)
144145

145-
istailcall(inst::Instruction) = convert(Core.Bool, API.LLVMIsTailCall(inst))
146-
tailcall!(inst::Instruction, bool) = API.LLVMSetTailCall(inst, convert(Bool, bool))
146+
istailcall(inst::CallBase) = convert(Core.Bool, API.LLVMIsTailCall(inst))
147+
tailcall!(inst::CallBase, bool) = API.LLVMSetTailCall(inst, convert(Bool, bool))
147148

148-
called_value(inst::Instruction) = Value(API.LLVMGetCalledValue(inst))
149+
called_value(inst::CallBase) = Value(API.LLVMGetCalledValue(inst))
149150

150-
function arguments(inst::Instruction)
151+
function arguments(inst::CallBase)
151152
nargs = API.LLVMGetNumArgOperands(inst)
152153
operands(inst)[1:nargs]
153154
end

0 commit comments

Comments
 (0)