tc-pru.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* Definitions for TI PRU assembler.
  2. Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
  4. This file is part of GAS, the GNU Assembler.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GAS; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. #ifndef __TC_PRU__
  18. #define __TC_PRU__
  19. #define TARGET_BYTES_BIG_ENDIAN 0
  20. /* Words are big enough to hold addresses. */
  21. #define WORKING_DOT_WORD 1
  22. extern const char *pru_target_format (void);
  23. #define TARGET_FORMAT pru_target_format ()
  24. #define TARGET_ARCH bfd_arch_pru
  25. /* A PRU instruction consists of tokens and separator characters
  26. the tokens are things like the instruction name (add, or jmp etc),
  27. the register indices ($5, $7 etc), and constant expressions. The
  28. separator characters are commas, brackets and space.
  29. The instruction name is always separated from other tokens by a space
  30. The maximum number of tokens in an instruction is 6 (the instruction name,
  31. 4 arguments, and a 4th string representing the expected instruction opcode
  32. after assembly. The latter is only used when the assemble is running in
  33. self test mode, otherwise its presence will generate an error. */
  34. #define PRU_MAX_INSN_TOKENS 7
  35. /* There are no machine-specific operands so we #define this to nothing. */
  36. #define md_operand(x)
  37. /* Function prototypes exported to rest of GAS. */
  38. extern void md_assemble (char *op_str);
  39. extern void md_end (void);
  40. extern void md_begin (void);
  41. #define tc_fix_adjustable(fixp) pru_fix_adjustable (fixp)
  42. extern int pru_fix_adjustable (struct fix *);
  43. #define tc_frob_label(lab) pru_frob_label (lab)
  44. extern void pru_frob_label (symbolS *);
  45. extern void md_convert_frag (bfd * headers, segT sec, fragS * fragP);
  46. #define DIFF_EXPR_OK
  47. /* FIXME This seems appropriate, given that we intentionally prevent
  48. PRU's .text from being used in a DIFF expression with symbols from
  49. other sections. Revisit once GDB is ported. */
  50. #define CFI_DIFF_EXPR_OK 0
  51. #define TC_PARSE_CONS_RETURN_TYPE int
  52. #define TC_PARSE_CONS_RETURN_NONE 0
  53. #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
  54. pru_parse_cons_expression (EXP, NBYTES)
  55. extern int pru_parse_cons_expression (expressionS *exp, int size);
  56. #define TC_CONS_FIX_NEW pru_cons_fix_new
  57. extern void pru_cons_fix_new (struct frag *frag, int where,
  58. unsigned int nbytes, struct expressionS *exp,
  59. const int is_pmem);
  60. /* If you define this macro, it means that `tc_gen_reloc' may return
  61. multiple relocation entries for a single fixup. In this case, the
  62. return value of `tc_gen_reloc' is a pointer to a null terminated
  63. array. */
  64. #undef RELOC_EXPANSION_POSSIBLE
  65. /* No shared lib support, so we don't need to ensure externally
  66. visible symbols can be overridden. */
  67. #define EXTERN_FORCE_RELOC 0
  68. /* If defined, this macro allows control over whether fixups for a
  69. given section will be processed when the linkrelax variable is
  70. set. Define it to zero and handle things in md_apply_fix instead. */
  71. #define TC_LINKRELAX_FIXUP(SEG) 0
  72. /* If this macro returns non-zero, it guarantees that a relocation will be
  73. emitted even when the value can be resolved locally. Do that if
  74. linkrelax is turned on. */
  75. #define TC_FORCE_RELOCATION(fix) pru_force_relocation (fix)
  76. #define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
  77. (GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg) || pru_force_relocation (fix))
  78. extern int pru_force_relocation (struct fix *);
  79. /* Do not use PC relative fixups and relocations for
  80. anything but real PCREL relocations. */
  81. #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
  82. (((FIX)->fx_r_type != BFD_RELOC_PRU_S10_PCREL) \
  83. && ((FIX)->fx_r_type != BFD_RELOC_PRU_U8_PCREL))
  84. /* Values passed to md_apply_fix don't include the symbol value. */
  85. #define MD_APPLY_SYM_VALUE(FIX) 0
  86. /* We don't want gas to fixup the following memory related relocations.
  87. We will need them in case that we want to do linker relaxation.
  88. We could in principle keep these fixups in gas when not relaxing.
  89. However, there is no serious performance penalty when making the linker
  90. make the fixup work. Check also that fx_addsy is not NULL, in order to
  91. make sure that the fixup refers to some sort of label. */
  92. #define TC_VALIDATE_FIX(FIXP,SEG,SKIP) \
  93. if ((FIXP->fx_r_type == BFD_RELOC_PRU_LDI32 \
  94. || FIXP->fx_r_type == BFD_RELOC_PRU_U16 \
  95. || FIXP->fx_r_type == BFD_RELOC_PRU_U16_PMEMIMM \
  96. || FIXP->fx_r_type == BFD_RELOC_PRU_S10_PCREL \
  97. || FIXP->fx_r_type == BFD_RELOC_PRU_U8_PCREL \
  98. || FIXP->fx_r_type == BFD_RELOC_PRU_32_PMEM \
  99. || FIXP->fx_r_type == BFD_RELOC_PRU_16_PMEM) \
  100. && FIXP->fx_addsy != NULL \
  101. && FIXP->fx_subsy == NULL) \
  102. { \
  103. symbol_mark_used_in_reloc (FIXP->fx_addsy); \
  104. goto SKIP; \
  105. }
  106. /* This macro is evaluated for any fixup with a fx_subsy that
  107. fixup_segment cannot reduce to a number. If the macro returns
  108. false an error will be reported. */
  109. #define TC_VALIDATE_FIX_SUB(fix, seg) pru_validate_fix_sub (fix)
  110. extern int pru_validate_fix_sub (struct fix *);
  111. /* We want .cfi_* pseudo-ops for generating unwind info. */
  112. #define TARGET_USE_CFIPOP 1
  113. /* Program Counter register number is not defined by TI documents.
  114. Pick the virtual number used by GCC. */
  115. #define DWARF2_DEFAULT_RETURN_COLUMN 132
  116. /* The stack grows down, and is only byte aligned. */
  117. #define DWARF2_CIE_DATA_ALIGNMENT -1
  118. #define tc_regname_to_dw2regnum pru_regname_to_dw2regnum
  119. extern int pru_regname_to_dw2regnum (char *regname);
  120. #define tc_cfi_frame_initial_instructions pru_frame_initial_instructions
  121. extern void pru_frame_initial_instructions (void);
  122. /* The difference between same-section symbols may be affected by linker
  123. relaxation, so do not resolve such expressions in the assembler. */
  124. #define md_allow_local_subtract(l,r,s) pru_allow_local_subtract (l, r, s)
  125. extern bool pru_allow_local_subtract (expressionS *, expressionS *, segT);
  126. #endif /* __TC_PRU__ */