The following post of @benoitrichard gave the solution:
I think what you need is a generated function then
@generated function logtable(::Type{G}) where {p, r, G <: GaloisField{p, r}}
lg = _logtable(p, r) # The actual computation
return :($lg)
end
That way the actual logtable will be comptued only once per type