hlcgcpu.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {
  2. Copyright (c) 1998-2010 by Florian Klaempfl and Jonas Maebe
  3. Member of the Free Pascal development team
  4. This unit contains high-level code generator support for riscv64
  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 hlcgcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. globtype,
  23. aasmdata,
  24. symtype,
  25. cgbase,cgutils,hlcgobj,hlcgrv;
  26. type
  27. thlcgcpu = class(thlcgriscv)
  28. procedure a_load_const_subsetreg(list: TAsmlist; tosubsetsize: tdef; a: tcgint; const sreg: tsubsetregister); override;
  29. end;
  30. procedure create_hlcodegen;
  31. implementation
  32. uses
  33. cpubase,aasmcpu,
  34. defutil,
  35. {$ifdef extdebug}
  36. aasmtai,cutils,cgrv,
  37. {$endif}
  38. cgobj,cgcpu;
  39. { thlcgcpu }
  40. procedure thlcgcpu.a_load_const_subsetreg(list: TAsmlist; tosubsetsize: tdef; a: tcgint; const sreg: tsubsetregister);
  41. var
  42. tmpreg : TRegister;
  43. begin
  44. {$ifdef extdebug}
  45. list.concat(tai_comment.create(strpnew('a_load_const_subsetreg subsetregsize = ' + cgsize2string(sreg.subsetregsize) + ' subsetsize = ' + cgsize2string(def_cgsize(tosubsetsize)) + ' startbit = ' + ToStr(sreg.startbit) + ' a = ' + ToStr(a))));
  46. {$endif}
  47. { loading the constant into the lowest bits of a temp register and then inserting is
  48. better than loading some usually large constants and do some masking and shifting on riscv64 }
  49. tmpreg:=getintregister(list,tosubsetsize);
  50. a_load_const_reg(list,tosubsetsize,a,tmpreg);
  51. a_load_reg_subsetreg(list,tosubsetsize,tosubsetsize,tmpreg,sreg);
  52. end;
  53. procedure create_hlcodegen;
  54. begin
  55. hlcg:=thlcgcpu.create;
  56. create_codegen;
  57. end;
  58. begin
  59. chlcgobj:=thlcgcpu;
  60. end.