racpu.pas 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 operands[1].opr.typ<>OPR_REGISTER then
  55. internalerror(2014122002);
  56. result:=reg_cgsize(operands[1].opr.reg);
  57. { a 32 bit integer register could actually be 16 or 8 bit }
  58. if result=OS_32 then
  59. case oppostfix of
  60. PF_B:
  61. result:=OS_8;
  62. PF_SB:
  63. result:=OS_S8;
  64. PF_H:
  65. result:=OS_16;
  66. PF_SH:
  67. result:=OS_S16;
  68. end;
  69. end;
  70. end.