Hello Jim thanks for the reply,<br><br>For normal additions with immediates I've done the same as ARM does, basically transforming add(x, imm) nodes to sub(x, -imm) with a pattern in the .td file like this:<br>def : Pat<(add DLDREGS:$src1, imm:$src2),<br>
              (SUBIWRdK DLDREGS:$src1, (imm16_neg_XFORM imm:$src2))>;<br><br>Now, the typical pattern concerning additions with global addresses looks like this: (taken from x86)<br>def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),<br>
              (ADD32ri GR32:$src1, tglobaladdr:$src2)>;<br><br>but i can't write that since i dont have an add with imm instr, and doing:<br><br>def : Pat<(add DREGS:$src, (Wrapper tglobaladdr:$src2)),<br>              (SUBIWRdK DREGS:$src, tglobaladdr:$src2)>;<br>
is wrong because the tglobaladdr has to be negated somehow, so i don't understand how should I negate the symbol reference using patterns, if it's even possible. The obvious hack is adding a "-" char when lowering the symbol reference into text.<br>
<br>Regarding my second question, as you mentioned all symbols have static addresses so no relocations are performed, so it should be safe to fold immediate operations with the symbol reference. My problem here is that i don't know how to fold an arbitrary expression on a global (initially in the form of a DAG) to something that can be translated later into an expression with MC. It's something weird because operations are performed in the operand of an instruction, and since it has to support any arbitrary expression you can't have all combinations of operations using custom instructions. So how should i proceed in here using custom lowering or target dag combines?<br>
<br>Thanks<br>