hlcgcpu.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. symdef,
  26. hlcgobj, hlcg2ll;
  27. type
  28. thlcg2mips = class(thlcg2ll)
  29. procedure a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; weak: boolean);override;
  30. end;
  31. procedure create_hlcodegen;
  32. implementation
  33. uses
  34. cgbase,
  35. cgutils,
  36. cgobj,
  37. cpubase,
  38. cgcpu;
  39. procedure thlcg2mips.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; weak: boolean);
  40. var
  41. ref : treference;
  42. begin
  43. if pd.proccalloption =pocall_cdecl then
  44. begin
  45. { Use $gp/$t9 registers as the code might be in a shared library }
  46. reference_reset(ref,sizeof(aint));
  47. ref.symbol:=current_asmdata.RefAsmSymbol('_gp');
  48. cg.a_loadaddr_ref_reg(list,ref,NR_GP);
  49. reference_reset(ref,sizeof(aint));
  50. ref.symbol:=current_asmdata.RefAsmSymbol(s);
  51. ref.base:=NR_GP;
  52. ref.refaddr:=addr_pic;
  53. cg.a_loadaddr_ref_reg(list,ref,NR_PIC_FUNC);
  54. cg.a_call_reg(list,NR_PIC_FUNC);
  55. end
  56. else
  57. cg.a_call_name(list,s,weak);
  58. end;
  59. procedure create_hlcodegen;
  60. begin
  61. hlcg:=thlcg2mips.create;
  62. create_codegen;
  63. end;
  64. end.