The custom_legalize() method on XFormGroup can be used to call a custom function to legalize specific opcodes. This will be used shortly to expand global_addr which has an expansion that depends on the details of the global variable being referenced.