Migrate build_ functions to use Target?

We’ve had Target and TargetNode for a while. When building a module, a Target object is created from a string, and then it is passed all the way to codegen::Build, but then it’s converted back to a string before the call to the target-specific build function:

runtime::Module Build(IRModule mod, const Target& target) {
  [...]
  return (*bf)(mod, target->str());
}

Some of that string parsing has already been done, and the TargetNode's members have been populated—wouldn’t it make sense to pass Target or TargetNode to the build function instead?

For sure we should eliminate the use of raw strings. Like right now, codegen passes are all using raw strings, which is largely error prone and incompatible with our newly proposed nested target objects.

1 Like