On Thu, Mar 12, 2009 at 1:31 PM, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info">anton@korobeynikov.info</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div class="im"><blockquote type="cite"><div style=""><div><blockquote type="cite"><div class="gmail_quote"><div>If any ARM/GCC experts know how to fix <a href="http://arm.md" target="_blank">arm.md</a> to not refer to Darwin-specific macros, that would be great, too.</div>
</div></blockquote></div><div>Probably the right general idea is to #define MACHO_DYNAMIC_NO_PIC_P to be 0 for non-Darwin targets. Not sure where to put this so it will work for both targets (the Darwin definition comes from config/darwin.h).</div>
</div></blockquote></div>I don't think so. Darwin-specific pieces of code should be guarded, as usual, with TARGET_MACHO define.</div></div></blockquote><div><br>Perhaps, but the problem is that MACHO_DYNAMIC_NO_PIC_P is so ingrained into the machine description, that if you try to guard each use with something like <br>
<br>#ifdef TARGET_MACHO<br> ...<br>#endif<br><br>you will get unreadable code for something as simple as:<br> <br></div></div><span style="font-family: courier new,monospace;">; APPLE LOCAL begin ARM pic support</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(define_insn "pic_load_addr_arm"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [(set (match_operand:SI 0 "s_register_operand" "=r")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (unspec:SI [(match_operand:SI 1 "" "mX")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (label_ref (match_operand 2 "" ""))] UNSPEC_PIC_SYM))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (use (label_ref (match_dup 2)))]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "TARGET_ARM && (flag_pic || (TARGET_MACHO && MACHO_DYNAMIC_NO_PIC_P))"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> "ldr%?\\t%0, %1"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [(set_attr "type" "load1")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (set (attr "pool_range") (const_int 4096))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (set (attr "neg_pool_range") (const_int 4084))]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">or, even more complex code sequence:<br><br><span style="font-family: courier new,monospace;">;; APPLE LOCAL begin compact switch tables</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">;; This pattern represents the library call for Thumb switch tables.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">;; The functions' (sparse) register usage is recorded as clobbers.</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define_insn "thumb_casesi_internal"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [(parallel [(set (pc)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (if_then_else</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (leu (match_operand:SI 0 "s_register_operand" "l")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (match_operand:SI 1 "const_int_operand" "i"))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 2))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (label_ref (match_operand 2 "" ""))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (label_ref (match_operand 3 "" ""))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (clobber (reg:CC CC_REGNUM))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (clobber (reg:SI LR_REGNUM))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (clobber (reg:SI IP_REGNUM))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (use (reg:SI 0))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (use (label_ref (match_dup 2)))])]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "TARGET_COMPACT_SWITCH_TABLES"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> "*</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> rtx body = PATTERN (next_real_insn (insn));</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> static char buf[255];</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gcc_assert (GET_CODE (body) == ADDR_DIFF_VEC);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> strcpy(buf, \"bl\\t\");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (flag_pic || MACHO_DYNAMIC_NO_PIC_P)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> strcat(buf, \"L\");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (GET_MODE (body) == QImode</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> && ADDR_DIFF_VEC_FLAGS (body).offset_unsigned)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> register_switchu8_libfunc ();</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[... more code below ...]</span><br><br>If this code is purely Darwin-specific, it shouldn't even appear in <a href="http://arm.md">arm.md</a> . If this is ARM-PIC-specific, then we should use a var such as ARM_PIC, and darwin.h can set the common ARM_PIC variable if MACHO_DYNAMIC_* is defined.<br>
<br>Adding #ifdef/#endif code to .md files will make what's already barely readable even less comprehensible.<br><br>Misha<br>