hlcgcpu.pas 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. {
  2. Copyright (c) 1998-2010 by Florian Klaempfl and Jonas Maebe
  3. Member of the Free Pascal development team
  4. This unit contains routines to create a pass-through high-level code
  5. generator. This is used by most regular code generators.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit hlcgcpu;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. globtype,
  24. aasmbase, aasmdata,
  25. cgbase, cgutils,
  26. symconst,symtype,symdef,
  27. parabase, hlcgobj, hlcg2ll;
  28. type
  29. thlcgm68k = class(thlcg2ll)
  30. procedure a_bit_set_reg_reg(list: TAsmList; doset: boolean; bitnumbersize, destsize: tdef; bitnumber, dest: tregister); override;
  31. procedure a_bit_set_const_reg(list: TAsmList; doset: boolean; destsize: tdef; bitnumber: tcgint; destreg: tregister); override;
  32. end;
  33. procedure create_hlcodegen;
  34. implementation
  35. uses
  36. verbose, systems,
  37. aasmtai,
  38. aasmcpu,
  39. cutils,
  40. globals,
  41. defutil,
  42. cgobj,
  43. cpubase,
  44. cpuinfo,
  45. cgcpu;
  46. procedure thlcgm68k.a_bit_set_reg_reg(list: TAsmList; doset: boolean; bitnumbersize, destsize: tdef; bitnumber, dest: tregister);
  47. const
  48. instr: array[boolean] of tasmop = (A_BCLR,A_BSET);
  49. var
  50. tmpvalue: tregister;
  51. begin
  52. tmpvalue:=getintregister(list,destsize);
  53. //list.concat(tai_comment.create(strpnew('a_bit_set_reg_reg: called!')));
  54. a_load_const_reg(list,u32inttype,destsize.size*8-1,tmpvalue);
  55. a_op_reg_reg(list,OP_SUB,bitnumbersize,bitnumber,tmpvalue);
  56. list.concat(taicpu.op_reg_reg(instr[doset],S_NO,tmpvalue,dest));
  57. end;
  58. procedure thlcgm68k.a_bit_set_const_reg(list: TAsmList; doset: boolean; destsize: tdef; bitnumber: tcgint; destreg: tregister);
  59. const
  60. instr: array[boolean] of tasmop = (A_BCLR,A_BSET);
  61. begin
  62. //list.concat(tai_comment.create(strpnew('a_bit_set_const_reg: called!')));
  63. list.concat(taicpu.op_const_reg(instr[doset],S_NO,(destsize.size*8)-bitnumber-1,destreg));
  64. end;
  65. procedure create_hlcodegen;
  66. begin
  67. hlcg:=thlcgm68k.create;
  68. create_codegen;
  69. end;
  70. end.