racpu.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. Copyright (c) 1998-2003 by Carl Eric Codere and Peter Vreman
  3. Copyright (c) 2014 by Jonas Maebe
  4. Handles the common AArch64 assembler reader routines
  5. This program 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 2 of the License, or
  8. (at your option) any later version.
  9. This program 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 this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit racpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cgbase,
  23. cpubase,
  24. aasmtai,aasmdata,
  25. rautils;
  26. type
  27. TAArch64Operand=class(TOperand)
  28. end;
  29. TAArch64Instruction=class(TInstruction)
  30. oppostfix : toppostfix;
  31. function ConcatInstruction(p:TAsmList) : tai;override;
  32. function Is64bit: boolean;
  33. function cgsize: tcgsize;
  34. end;
  35. implementation
  36. uses
  37. verbose,
  38. aasmcpu;
  39. function TAArch64Instruction.ConcatInstruction(p:TAsmList) : tai;
  40. begin
  41. result:=inherited ConcatInstruction(p);
  42. taicpu(result).oppostfix:=oppostfix;
  43. end;
  44. function TAArch64Instruction.Is64bit: boolean;
  45. begin
  46. result:=
  47. (operands[1].opr.typ=OPR_REGISTER) and
  48. (getsubreg(operands[1].opr.reg)=R_SUBQ);
  49. end;
  50. function TAArch64Instruction.cgsize: tcgsize;
  51. begin
  52. if ops<1 then
  53. internalerror(2014122001);
  54. if (ops=1) and (operands[1].opr.typ=OPR_REFERENCE) then
  55. exit(OS_NO);
  56. case operands[1].opr.typ of
  57. OPR_REGISTER:
  58. result:=reg_cgsize(operands[1].opr.reg);
  59. OPR_INDEXEDREG:
  60. result:=reg_cgsize(operands[1].opr.indexedreg);
  61. OPR_REGSET:
  62. result:=OS_NO;
  63. else
  64. internalerror(2014122002);
  65. end;
  66. { a 32 bit integer register could actually be 16 or 8 bit }
  67. if result=OS_32 then
  68. case oppostfix of
  69. PF_NONE: ;
  70. PF_B:
  71. result:=OS_8;
  72. PF_SB:
  73. result:=OS_S8;
  74. PF_H:
  75. result:=OS_16;
  76. PF_SH:
  77. result:=OS_S16;
  78. else
  79. Message(asmr_e_invalid_opcode_and_operand)
  80. end;
  81. end;
  82. end.