Skip to content

Commit 111f192

Browse files
authored
Merge pull request #261 from maleadt/tb/float_types
Add support for less common floating-point types.
2 parents 21122ab + d93d860 commit 111f192

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/core/type.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ width(inttyp::IntegerType) = API.LLVMGetIntTypeWidth(inttyp)
7777
# we add it for convenience of typechecking generic values (see execution.jl)
7878
abstract type FloatingPointType <: LLVMType end
7979

80-
# NOTE: we don't handle the obscure types here (:X86FP80, :FP128, :PPCFP128),
81-
# they would also need special casing as LLVMPPCFP128Type != LLVMPPC_FP128TypeKind
82-
for T in [:Half, :Float, :Double]
83-
jl_fname = Symbol(T, :Type)
84-
api_typename = Symbol(:LLVM, T)
80+
for T in [:Half, :Float, :Double, :FP128, :X86_FP80, :PPC_FP128]
81+
CleanT = Symbol(replace(String(T), "_"=>"")) # only the type kind retains the underscore
82+
jl_fname = Symbol(CleanT, :Type)
83+
api_typename = Symbol(:LLVM, CleanT)
8584
api_fname = Symbol(:LLVM, jl_fname)
8685
enumkind = Symbol(:LLVM, T, :TypeKind)
8786
@eval begin

test/core.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,18 @@ Context() do ctx
384384
c = ConstantFP(typ, 1.1)
385385
@test convert(Float64, c) == 1.1
386386
end
387+
let
388+
typ = LLVM.X86FP80Type(ctx)
389+
# TODO: how to construct full-width constants?
390+
c = ConstantFP(typ, 1.1)
391+
@test convert(Float64, c) == 1.1
392+
end
393+
for T in [LLVM.FP128Type, LLVM.PPCFP128Type]
394+
typ = T(ctx)
395+
# TODO: how to construct full-width constants?
396+
c = ConstantFP(typ, 1.1)
397+
@test convert(Float64, c) == 1.1
398+
end
387399
for T in [Float16, Float32, Float64]
388400
c = ConstantFP(typemax(T); ctx)
389401
@test convert(T, c) == typemax(T)

0 commit comments

Comments
 (0)