📄 thumb.h
字号:
/* Definitions of target machine for GNU compiler, for ARM/Thumb. Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. The basis of this contribution was generated by Richard Earnshaw, Advanced RISC Machines LtdThis file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING. If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA. *//* ??? The files thumb.{c,h,md} are all seriously lacking comments. *//* ??? The files thumb.{c,h,md} need to be reviewed by an experienced gcc hacker in their entirety. *//* ??? The files thumb.{c,h,md} and tcoff.h are all separate from the arm files, which will lead to many maintenance problems. These files are likely missing all bug fixes made to the arm port since they diverged. *//* ??? Many patterns in the md file accept operands that will require a reload. These should be eliminated if possible by tightening the predicates and/or constraints. This will give faster/smaller code. *//* ??? There is no pattern for the TST instuction. Check for other unsupported instructions. *//* Run Time Target Specifications */#ifndef CPP_PREDEFINES#define CPP_PREDEFINES "-Dthumb -D__thumb -Acpu(arm) -Amachine(arm)"#endif#ifndef CPP_SPEC#define CPP_SPEC "\%{mbig-endian:-D__ARMEB__ -D__THUMBEB__} \%{mbe:-D__ARMEB__ -D__THUMBEB__} \%{!mbe: %{!mbig-endian:-D__ARMEL__ -D__THUMBEL__}} \"#endif#define ASM_SPEC "-marm7tdmi %{mthumb-interwork:-mthumb-interwork} %{mbig-endian:-EB}"#define LINK_SPEC "%{mbig-endian:-EB} -X"#define TARGET_VERSION fputs (" (ARM/THUMB:generic)", stderr);/* Nonzero if we should compile with BYTES_BIG_ENDIAN set to 1. */#define THUMB_FLAG_BIG_END 0x0001#define THUMB_FLAG_BACKTRACE 0x0002#define THUMB_FLAG_LEAF_BACKTRACE 0x0004#define ARM_FLAG_THUMB 0x1000 /* same as in arm.h */#define THUMB_FLAG_CALLEE_SUPER_INTERWORKING 0x40000 #define THUMB_FLAG_CALLER_SUPER_INTERWORKING 0x80000 /* Run-time compilation parameters selecting different hardware/software subsets. */extern int target_flags;#define TARGET_DEFAULT 0 /* ARM_FLAG_THUMB */#define TARGET_BIG_END (target_flags & THUMB_FLAG_BIG_END)#define TARGET_THUMB_INTERWORK (target_flags & ARM_FLAG_THUMB)#define TARGET_BACKTRACE (leaf_function_p() \ ? (target_flags & THUMB_FLAG_LEAF_BACKTRACE) \ : (target_flags & THUMB_FLAG_BACKTRACE))/* Set if externally visable functions should assume that they might be called in ARM mode, from a non-thumb aware code. */#define TARGET_CALLEE_INTERWORKING \ (target_flags & THUMB_FLAG_CALLEE_SUPER_INTERWORKING)/* Set if calls via function pointers should assume that their destination is non-Thumb aware. */#define TARGET_CALLER_INTERWORKING \ (target_flags & THUMB_FLAG_CALLER_SUPER_INTERWORKING)/* SUBTARGET_SWITCHES is used to add flags on a per-config basis. */#ifndef SUBTARGET_SWITCHES#define SUBTARGET_SWITCHES#endif#define TARGET_SWITCHES \{ \ {"big-endian", THUMB_FLAG_BIG_END}, \ {"little-endian", -THUMB_FLAG_BIG_END}, \ {"thumb-interwork", ARM_FLAG_THUMB}, \ {"no-thumb-interwork", -ARM_FLAG_THUMB}, \ {"tpcs-frame", THUMB_FLAG_BACKTRACE}, \ {"no-tpcs-frame", -THUMB_FLAG_BACKTRACE}, \ {"tpcs-leaf-frame", THUMB_FLAG_LEAF_BACKTRACE}, \ {"no-tpcs-leaf-frame", -THUMB_FLAG_LEAF_BACKTRACE}, \ {"callee-super-interworking", THUMB_FLAG_CALLEE_SUPER_INTERWORKING}, \ {"no-callee-super-interworking", -THUMB_FLAG_CALLEE_SUPER_INTERWORKING}, \ {"caller-super-interworking", THUMB_FLAG_CALLER_SUPER_INTERWORKING}, \ {"no-caller-super-interworking", -THUMB_FLAG_CALLER_SUPER_INTERWORKING}, \ SUBTARGET_SWITCHES \ {"", TARGET_DEFAULT} \}#define TARGET_OPTIONS \{ \ { "structure-size-boundary=", & structure_size_string }, \}#define REGISTER_PREFIX ""#define CAN_DEBUG_WITHOUT_FP 1#define ASM_APP_ON ""#define ASM_APP_OFF "\t.code\t16\n"/* Output a gap. In fact we fill it with nulls. */#define ASM_OUTPUT_SKIP(STREAM, NBYTES) \ fprintf ((STREAM), "\t.space\t%u\n", (NBYTES))/* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */#define ASM_OUTPUT_ALIGN(STREAM,LOG) \{ \ fprintf (STREAM, "\t.align\t%d\n", (LOG)); \}/* Output a common block */#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \ (fprintf ((STREAM), "\t.comm\t"), \ assemble_name ((STREAM), (NAME)), \ fprintf((STREAM), ", %d\t%s %d\n", (ROUNDED), (ASM_COMMENT_START), (SIZE)))#define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \ sprintf ((STRING), "*%s%s%d", (LOCAL_LABEL_PREFIX), (PREFIX), (NUM))/* This is how to output an internal numbered label where PREFIX is the class of label and NUM is the number within the class. */#define ASM_OUTPUT_INTERNAL_LABEL(STREAM,PREFIX,NUM) \ fprintf ((STREAM), "%s%s%d:\n", (LOCAL_LABEL_PREFIX), (PREFIX), (NUM))/* This is how to output a label which precedes a jumptable. Since instructions are 2 bytes, we need explicit alignment here. */#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \ do { \ ASM_OUTPUT_ALIGN (FILE, 2); \ ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \ } while (0)/* This says how to define a local common symbol (ie, not visible to linker). */#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED) \ (fprintf((STREAM),"\n\t.lcomm\t"), \ assemble_name((STREAM),(NAME)), \ fprintf((STREAM),",%u\n",(SIZE)))/* Output a reference to a label. */#define ASM_OUTPUT_LABELREF(STREAM,NAME) \ fprintf ((STREAM), "%s%s", user_label_prefix, (NAME))/* This is how to output an assembler line for a numeric constant byte. */#define ASM_OUTPUT_BYTE(STREAM,VALUE) \ fprintf ((STREAM), "\t.byte\t0x%x\n", (VALUE))#define ASM_OUTPUT_INT(STREAM,VALUE) \{ \ fprintf (STREAM, "\t.word\t"); \ output_addr_const (STREAM, (VALUE)); \ fprintf (STREAM, "\n"); \}#define ASM_OUTPUT_SHORT(STREAM,VALUE) \{ \ fprintf (STREAM, "\t.short\t"); \ output_addr_const (STREAM, (VALUE)); \ fprintf (STREAM, "\n"); \}#define ASM_OUTPUT_CHAR(STREAM,VALUE) \{ \ fprintf (STREAM, "\t.byte\t"); \ output_addr_const (STREAM, (VALUE)); \ fprintf (STREAM, "\n"); \}#define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \do { char dstr[30]; \ long l[3]; \ REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \ REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ fprintf (STREAM, "\t.long 0x%lx,0x%lx,0x%lx\t%s long double %s\n", \ l[0], l[1], l[2], ASM_COMMENT_START, dstr); \ } while (0)#define ASM_OUTPUT_DOUBLE(STREAM, VALUE) \do { char dstr[30]; \ long l[2]; \ REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \ REAL_VALUE_TO_DECIMAL (VALUE, "%.14g", dstr); \ fprintf (STREAM, "\t.long 0x%lx, 0x%lx\t%s double %s\n", l[0], \ l[1], ASM_COMMENT_START, dstr); \ } while (0)#define ASM_OUTPUT_FLOAT(STREAM, VALUE) \do { char dstr[30]; \ long l; \ REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ REAL_VALUE_TO_DECIMAL (VALUE, "%.7g", dstr); \ fprintf (STREAM, "\t.word 0x%lx\t%s float %s\n", l, \ ASM_COMMENT_START, dstr); \ } while (0);/* Define results of standard character escape sequences. */#define TARGET_BELL 007#define TARGET_BS 010#define TARGET_TAB 011#define TARGET_NEWLINE 012#define TARGET_VT 013#define TARGET_FF 014#define TARGET_CR 015/* This is how to output a string. */#define ASM_OUTPUT_ASCII(STREAM, STRING, LEN) \do { \ register int i, c, len = (LEN), cur_pos = 17; \ register unsigned char *string = (unsigned char *)(STRING); \ fprintf ((STREAM), "\t.ascii\t\""); \ for (i = 0; i < len; i++) \ { \ register int c = string[i]; \ \ switch (c) \ { \ case '\"': \ case '\\': \ putc ('\\', (STREAM)); \ putc (c, (STREAM)); \ cur_pos += 2; \ break; \ \ case TARGET_NEWLINE: \ fputs ("\\n", (STREAM)); \ if (i+1 < len \ && (((c = string[i+1]) >= '\040' && c <= '~') \ || c == TARGET_TAB)) \ cur_pos = 32767; /* break right here */ \ else \ cur_pos += 2; \ break; \ \ case TARGET_TAB: \ fputs ("\\t", (STREAM)); \ cur_pos += 2; \ break; \ \ case TARGET_FF: \ fputs ("\\f", (STREAM)); \ cur_pos += 2; \ break; \ \ case TARGET_BS: \ fputs ("\\b", (STREAM)); \ cur_pos += 2; \ break; \ \ case TARGET_CR: \ fputs ("\\r", (STREAM)); \ cur_pos += 2; \ break; \ \ default: \ if (c >= ' ' && c < 0177) \ { \ putc (c, (STREAM)); \ cur_pos++; \ } \ else \ { \ fprintf ((STREAM), "\\%03o", c); \ cur_pos += 4; \ } \ } \ \ if (cur_pos > 72 && i+1 < len) \ { \ cur_pos = 17; \ fprintf ((STREAM), "\"\n\t.ascii\t\""); \ } \ } \ fprintf ((STREAM), "\"\n"); \} while (0)/* Output and Generation of Labels */#define ASM_OUTPUT_LABEL(STREAM,NAME) \ (assemble_name ((STREAM), (NAME)), \ fprintf ((STREAM), ":\n"))#define ASM_GLOBALIZE_LABEL(STREAM,NAME) \ (fprintf ((STREAM), "\t.globl\t"), \ assemble_name ((STREAM), (NAME)), \ fputc ('\n', (STREAM)))/* Construct a private name. */#define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \ ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \ sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))/* Switch to the text or data segment. */#define TEXT_SECTION_ASM_OP ".text"#define DATA_SECTION_ASM_OP ".data"#define BSS_SECTION_ASM_OP ".bss"/* The assembler's names for the registers. */#ifndef REGISTER_NAMES#define REGISTER_NAMES \{ \ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc", "ap" \}#endif#ifndef ADDITIONAL_REGISTER_NAMES#define ADDITIONAL_REGISTER_NAMES \{ \ {"a1", 0}, \ {"a2", 1}, \ {"a3", 2}, \ {"a4", 3}, \ {"v1", 4}, \ {"v2", 5}, \ {"v3", 6}, \ {"v4", 7}, \ {"v5", 8}, \ {"v6", 9}, \ {"sb", 9}, \ {"v7", 10}, \ {"r10", 10}, /* sl */ \ {"r11", 11}, /* fp */ \ {"r12", 12}, /* ip */ \ {"r13", 13}, /* sp */ \ {"r14", 14}, /* lr */ \ {"r15", 15} /* pc */ \}#endif/* The assembler's parentheses characters. */#define ASM_OPEN_PAREN "("#define ASM_CLOSE_PAREN ")"#ifndef ASM_COMMENT_START#define ASM_COMMENT_START "@"#endif/* Output an element of a dispatch table. */#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \ fprintf (STREAM, "\t.word\t%sL%d\n", (LOCAL_LABEL_PREFIX), (VALUE))#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \ fprintf (STREAM, "\tb\t%sL%d\n", (LOCAL_LABEL_PREFIX), (VALUE))/* Storage Layout *//* Define this is most significant bit is lowest numbered in instructions that operate on numbered bit-fields. */#define BITS_BIG_ENDIAN 0/* Define this if most significant byte of a word is the lowest numbered. */#define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)/* LIBGCC2_WORDS_BIG_ENDIAN has to be a constant, so we define this based on processor pre-defineds when compiling libgcc2.c. */#if defined(__THUMBEB__) && !defined(__THUMBEL__)#define LIBGCC2_WORDS_BIG_ENDIAN 1#else#define LIBGCC2_WORDS_BIG_ENDIAN 0#endif#define FLOAT_WORDS_BIG_ENDIAN 1#define BITS_PER_UNIT 8#define BITS_PER_WORD 32#define UNITS_PER_WORD 4#define POINTER_SIZE 32#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \{ \ if (GET_MODE_CLASS (MODE) == MODE_INT \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -