hlcgcpu.pas 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. thlcgmips = class(thlcg2ll)
  30. function a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara; override;
  31. end;
  32. procedure create_hlcodegen;
  33. implementation
  34. uses
  35. aasmtai,
  36. cutils,
  37. globals,
  38. cgobj,
  39. cpubase,
  40. cgcpu;
  41. function thlcgmips.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara;
  42. var
  43. ref: treference;
  44. sym: tasmsymbol;
  45. begin
  46. if weak then
  47. sym:=current_asmdata.WeakRefAsmSymbol(s)
  48. else
  49. sym:=current_asmdata.RefAsmSymbol(s);
  50. if (po_external in pd.procoptions) then
  51. begin
  52. if not (cs_create_pic in current_settings.moduleswitches) then
  53. begin
  54. reference_reset_symbol(ref,current_asmdata.RefAsmSymbol('_gp'),0,sizeof(aint));
  55. list.concat(tai_comment.create(strpnew('Using PIC code for a_call_name')));
  56. cg.a_loadaddr_ref_reg(list,ref,NR_GP);
  57. end;
  58. TCGMIPS(cg).a_call_sym_pic(list,sym);
  59. end
  60. else
  61. cg.a_call_name(list,s,weak);
  62. { set the result location }
  63. result:=get_call_result_cgpara(pd,forceresdef);
  64. end;
  65. procedure create_hlcodegen;
  66. begin
  67. hlcg:=thlcgmips.create;
  68. create_codegen;
  69. end;
  70. end.