[LLVMdev] Consumer ARM platform suitable for LLVM development?

Misha Brukman brukman at gmail.com
Thu Mar 12 12:05:14 PDT 2009


On Thu, Mar 12, 2009 at 1:31 PM, Anton Korobeynikov <anton at korobeynikov.info
> wrote:

> If any ARM/GCC experts know how to fix arm.md to not refer to
> Darwin-specific macros, that would be great, too.
>
> 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).
>
> I don't think so. Darwin-specific pieces of code should be guarded, as
> usual, with TARGET_MACHO define.
>

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

#ifdef TARGET_MACHO
  ...
#endif

you will get unreadable code for something as simple as:

; APPLE LOCAL begin ARM pic support
(define_insn "pic_load_addr_arm"
  [(set (match_operand:SI 0 "s_register_operand" "=r")
  (unspec:SI [(match_operand:SI 1 "" "mX")
        (label_ref (match_operand 2 "" ""))] UNSPEC_PIC_SYM))
   (use (label_ref (match_dup 2)))]
  "TARGET_ARM && (flag_pic || (TARGET_MACHO && MACHO_DYNAMIC_NO_PIC_P))"
  "ldr%?\\t%0, %1"
  [(set_attr "type" "load1")
   (set (attr "pool_range")     (const_int 4096))
   (set (attr "neg_pool_range") (const_int 4084))]
)

or, even more complex code sequence:

;; APPLE LOCAL begin compact switch tables
;; This pattern represents the library call for Thumb switch tables.
;; The functions' (sparse) register usage is recorded as clobbers.

(define_insn "thumb_casesi_internal"
  [(parallel [(set (pc)
         (if_then_else
    (leu (match_operand:SI 0 "s_register_operand" "l")
         (match_operand:SI 1 "const_int_operand" "i"))
    (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 2))
         (label_ref (match_operand 2 "" ""))))
    (label_ref (match_operand 3 "" ""))))
        (clobber (reg:CC CC_REGNUM))
        (clobber (reg:SI LR_REGNUM))
        (clobber (reg:SI IP_REGNUM))
        (use (reg:SI 0))
        (use (label_ref (match_dup 2)))])]
  "TARGET_COMPACT_SWITCH_TABLES"
  "*
    {
      rtx body = PATTERN (next_real_insn (insn));
      static char buf[255];
      gcc_assert (GET_CODE (body) == ADDR_DIFF_VEC);
      strcpy(buf, \"bl\\t\");
      if (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
    strcat(buf, \"L\");
      if (GET_MODE (body) == QImode
    && ADDR_DIFF_VEC_FLAGS (body).offset_unsigned)
  {
    register_switchu8_libfunc ();

[... more code below ...]

If this code is purely Darwin-specific, it shouldn't even appear in
arm.md.  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.

Adding #ifdef/#endif code to .md files will make what's already barely
readable even less comprehensible.

Misha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090312/44c717ee/attachment.html>


More information about the llvm-dev mailing list