Skip to content

Commit 9dccb2c

Browse files
committed
Formatting changes
1 parent bf097de commit 9dccb2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2993
-2630
lines changed

examples/jit.jl

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module TestRuntime
1919
end
2020

2121
struct TestCompilerParams <: AbstractCompilerParams end
22-
GPUCompiler.runtime_module(::CompilerJob{<:Any,TestCompilerParams}) = TestRuntime
22+
GPUCompiler.runtime_module(::CompilerJob{<:Any, TestCompilerParams}) = TestRuntime
2323

2424

2525
## JIT integration
@@ -58,8 +58,8 @@ const jit = Ref{CompilerInstance}()
5858
function get_trampoline(job)
5959
compiler = jit[]
6060
lljit = compiler.jit
61-
lctm = compiler.lctm
62-
ism = compiler.ism
61+
lctm = compiler.lctm
62+
ism = compiler.ism
6363

6464
# We could also use one dylib per job
6565
jd = JITDylib(lljit)
@@ -68,11 +68,14 @@ function get_trampoline(job)
6868
target_sym = String(gensym(:target))
6969
flags = LLVM.API.LLVMJITSymbolFlags(
7070
LLVM.API.LLVMJITSymbolGenericFlagsCallable |
71-
LLVM.API.LLVMJITSymbolGenericFlagsExported, 0)
71+
LLVM.API.LLVMJITSymbolGenericFlagsExported, 0
72+
)
7273
entry = LLVM.API.LLVMOrcCSymbolAliasMapPair(
7374
mangle(lljit, entry_sym),
7475
LLVM.API.LLVMOrcCSymbolAliasMapEntry(
75-
mangle(lljit, target_sym), flags))
76+
mangle(lljit, target_sym), flags
77+
)
78+
)
7679

7780
mu = LLVM.reexports(lctm, ism, jd, Ref(entry))
7881
LLVM.define(jd, mu)
@@ -85,7 +88,7 @@ function get_trampoline(job)
8588

8689
function materialize(mr)
8790
buf = JuliaContext() do ctx
88-
ir, meta = GPUCompiler.compile(:llvm, job; validate=false)
91+
ir, meta = GPUCompiler.compile(:llvm, job; validate = false)
8992

9093
# Rename entry to match target_sym
9194
LLVM.name!(meta.entry, target_sym)
@@ -117,14 +120,14 @@ function get_trampoline(job)
117120
end
118121

119122
import GPUCompiler: deferred_codegen_jobs
120-
@generated function deferred_codegen(f::F, ::Val{tt}, ::Val{world}) where {F,tt,world}
123+
@generated function deferred_codegen(f::F, ::Val{tt}, ::Val{world}) where {F, tt, world}
121124
# manual version of native_job because we have a function type
122125
source = methodinstance(F, Base.to_tuple_type(tt), world)
123-
target = NativeCompilerTarget(; jlruntime=true, llvm_always_inline=true)
126+
target = NativeCompilerTarget(; jlruntime = true, llvm_always_inline = true)
124127
# XXX: do we actually require the Julia runtime?
125128
# with jlruntime=false, we reach an unreachable.
126129
params = TestCompilerParams()
127-
config = CompilerConfig(target, params; kernel=false)
130+
config = CompilerConfig(target, params; kernel = false)
128131
job = CompilerJob(source, config, world)
129132
# XXX: invoking GPUCompiler from a generated function is not allowed!
130133
# for things to work, we need to forward the correct world, at least.
@@ -135,16 +138,16 @@ import GPUCompiler: deferred_codegen_jobs
135138

136139
deferred_codegen_jobs[id] = job
137140

138-
quote
141+
return quote
139142
ptr = ccall("extern deferred_codegen", llvmcall, Ptr{Cvoid}, (Ptr{Cvoid},), $trampoline)
140143
assume(ptr != C_NULL)
141144
return ptr
142145
end
143146
end
144147

145148
@generated function abi_call(f::Ptr{Cvoid}, rt::Type{RT}, tt::Type{T}, func::F, args::Vararg{Any, N}) where {T, RT, F, N}
146-
argtt = tt.parameters[1]
147-
rettype = rt.parameters[1]
149+
argtt = tt.parameters[1]
150+
rettype = rt.parameters[1]
148151
argtypes = DataType[argtt.parameters...]
149152

150153
argexprs = Union{Expr, Symbol}[]
@@ -199,7 +202,7 @@ end
199202
if GPUCompiler.isghosttype(rettype) || Core.Compiler.isconstType(rettype)
200203
# Do nothing...
201204
# In theory we could set `rettype` to `T_void`, but ccall will do that for us
202-
# elseif jl_is_uniontype?
205+
# elseif jl_is_uniontype?
203206
elseif !GPUCompiler.deserves_retbox(rettype)
204207
rt = convert(LLVMType, rettype)
205208
if !isa(rt, LLVM.VoidType) && GPUCompiler.deserves_sret(rettype, rt)
@@ -214,26 +217,26 @@ end
214217
end
215218
end
216219

217-
quote
220+
return quote
218221
$before
219222
ret = ccall(f, $rettype, ($(ccall_types...),), $(argexprs...))
220223
$after
221224
end
222225
end
223226

224-
@inline function call_delayed(f::F, args...) where F
227+
@inline function call_delayed(f::F, args...) where {F}
225228
tt = Tuple{map(Core.Typeof, args)...}
226229
rt = Core.Compiler.return_type(f, tt)
227230
world = GPUCompiler.tls_world_age()
228231
ptr = deferred_codegen(f, Val(tt), Val(world))
229-
abi_call(ptr, rt, tt, f, args...)
232+
return abi_call(ptr, rt, tt, f, args...)
230233
end
231234

232235
optlevel = LLVM.API.LLVMCodeGenLevelDefault
233-
tm = GPUCompiler.JITTargetMachine(optlevel=optlevel)
236+
tm = GPUCompiler.JITTargetMachine(optlevel = optlevel)
234237
LLVM.asm_verbosity!(tm, true)
235238

236-
lljit = LLJIT(;tm)
239+
lljit = LLJIT(; tm)
237240

238241
jd_main = JITDylib(lljit)
239242

@@ -267,36 +270,36 @@ using Test
267270
f(A) = (A[] += 42; nothing)
268271
global flag = [0]
269272
function caller()
270-
call_delayed(f, flag::Vector{Int})
273+
return call_delayed(f, flag::Vector{Int})
271274
end
272275
@test caller() === nothing
273276
@test flag[] == 42
274277

275278
# test that we can call a function with a return value
276-
add(x, y) = x+y
279+
add(x, y) = x + y
277280
function call_add(x, y)
278-
call_delayed(add, x, y)
281+
return call_delayed(add, x, y)
279282
end
280283
@test call_add(1, 3) == 4
281284

282285
incr(r) = r[] += 1
283286
function call_incr(r)
284-
call_delayed(incr, r)
287+
return call_delayed(incr, r)
285288
end
286289
r = Ref{Int}(0)
287290
@test call_incr(r) == 1
288291
@test r[] == 1
289292

290293
function call_real(c)
291-
call_delayed(real, c)
294+
return call_delayed(real, c)
292295
end
293-
@test call_real(1.0+im) == 1.0
296+
@test call_real(1.0 + im) == 1.0
294297

295298
# tests struct return
296299
if Sys.ARCH != :aarch64
297-
@test call_delayed(complex, 1.0, 2.0) == 1.0+2.0im
300+
@test call_delayed(complex, 1.0, 2.0) == 1.0 + 2.0im
298301
else
299-
@test_broken call_delayed(complex, 1.0, 2.0) == 1.0+2.0im
302+
@test_broken call_delayed(complex, 1.0, 2.0) == 1.0 + 2.0im
300303
end
301304

302305
throws(arr, i) = arr[i]
@@ -306,11 +309,11 @@ throws(arr, i) = arr[i]
306309
struct Closure
307310
x::Int64
308311
end
309-
(c::Closure)(b) = c.x+b
312+
(c::Closure)(b) = c.x + b
310313
@test call_delayed(Closure(3), 5) == 8
311314

312315
struct Closure2
313316
x::Integer
314317
end
315-
(c::Closure2)(b) = c.x+b
318+
(c::Closure2)(b) = c.x + b
316319
@test call_delayed(Closure2(3), 5) == 8

examples/kernel.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module TestRuntime
1111
end
1212

1313
struct TestCompilerParams <: AbstractCompilerParams end
14-
GPUCompiler.runtime_module(::CompilerJob{<:Any,TestCompilerParams}) = TestRuntime
14+
GPUCompiler.runtime_module(::CompilerJob{<:Any, TestCompilerParams}) = TestRuntime
1515

1616
kernel() = nothing
1717

@@ -26,7 +26,7 @@ function main()
2626
GPUCompiler.compile(:asm, job)
2727
end
2828

29-
println(output[1])
29+
return println(output[1])
3030
end
3131

3232
isinteractive() || main()

src/GPUCompiler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function __init__()
6666
global compile_cache = dir
6767

6868
Tracy.@register_tracepoints()
69-
register_deferred_codegen()
69+
return register_deferred_codegen()
7070
end
7171

7272
end # module

src/bpf.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
export BPFCompilerTarget
66

77
Base.@kwdef struct BPFCompilerTarget <: AbstractCompilerTarget
8-
function_pointers::UnitRange{Int}=1:1000 # set of valid function "pointers"
8+
function_pointers::UnitRange{Int} = 1:1000 # set of valid function "pointers"
99
end
1010

1111
llvm_triple(::BPFCompilerTarget) = "bpf-bpf-bpf"
1212
llvm_datalayout(::BPFCompilerTarget) = "e-m:e-p:64:64-i64:64-n32:64-S128"
1313

1414
function llvm_machine(target::BPFCompilerTarget)
1515
triple = llvm_triple(target)
16-
t = Target(;triple=triple)
16+
t = Target(; triple = triple)
1717

1818
cpu = ""
1919
feat = ""

src/debug.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function backtrace(inst::LLVM.Instruction, bt = StackTraces.StackFrame[])
1919
while loc !== nothing
2020
scope = LLVM.scope(loc)
2121
if scope !== nothing
22-
name = replace(LLVM.name(scope), r";$"=>"")
22+
name = replace(LLVM.name(scope), r";$" => "")
2323
file = LLVM.file(scope)
2424
path = joinpath(LLVM.directory(file), LLVM.filename(file))
2525
line = LLVM.line(loc)

0 commit comments

Comments
 (0)