hlcgx86.pas 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 hlcgx86;
  20. interface
  21. {$i fpcdefs.inc}
  22. uses
  23. globtype,
  24. aasmdata,
  25. symtype,symdef,
  26. parabase,
  27. hlcgobj, hlcg2ll;
  28. type
  29. { thlcgx86 }
  30. thlcgx86 = class(thlcg2ll)
  31. protected
  32. procedure gen_load_uninitialized_function_result(list: TAsmList; pd: tprocdef; resdef: tdef; const resloc: tcgpara); override;
  33. procedure a_jmp_external_name(list: TAsmList; const externalname: TSymStr); override;
  34. end;
  35. implementation
  36. uses
  37. globals,systems,
  38. aasmbase,
  39. cgbase,cgutils,
  40. cpubase,aasmcpu;
  41. { thlcgx86 }
  42. procedure thlcgx86.gen_load_uninitialized_function_result(list: TAsmList; pd: tprocdef; resdef: tdef; const resloc: tcgpara);
  43. begin
  44. { the caller will pop a value from the fpu stack }
  45. if assigned(resloc.location) and
  46. (resloc.location^.loc=LOC_FPUREGISTER) then
  47. list.concat(taicpu.op_none(A_FLDZ));
  48. end;
  49. procedure thlcgx86.a_jmp_external_name(list: TAsmList; const externalname: TSymStr);
  50. var
  51. ref : treference;
  52. sym : tasmsymbol;
  53. begin
  54. if (target_info.system = system_i386_darwin) then
  55. begin
  56. { a_jmp_name jumps to a stub which is always pic-safe on darwin }
  57. inherited;
  58. exit;
  59. end;
  60. sym:=current_asmdata.RefAsmSymbol(externalname,AT_FUNCTION);
  61. reference_reset_symbol(ref,sym,0,sizeof(pint),[]);
  62. { create pic'ed? }
  63. if (cs_create_pic in current_settings.moduleswitches) and
  64. { darwin/x86_64's assembler doesn't want @PLT after call symbols }
  65. not(target_info.system in [system_x86_64_darwin,system_i386_iphonesim,system_x86_64_iphonesim]) then
  66. ref.refaddr:=addr_pic
  67. else
  68. ref.refaddr:=addr_full;
  69. list.concat(taicpu.op_ref(A_JMP,S_NO,ref));
  70. end;
  71. end.