hlcgx86.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. public
  35. procedure a_load_undefined_cgpara(list: TAsmList; size: tdef; const cgpara: TCGPara); override;
  36. end;
  37. implementation
  38. uses
  39. globals,systems,
  40. aasmbase,
  41. cgbase,cgutils,
  42. cpubase,aasmcpu;
  43. { thlcgx86 }
  44. procedure thlcgx86.gen_load_uninitialized_function_result(list: TAsmList; pd: tprocdef; resdef: tdef; const resloc: tcgpara);
  45. begin
  46. { the caller will pop a value from the fpu stack }
  47. if assigned(resloc.location) and
  48. (resloc.location^.loc=LOC_FPUREGISTER) then
  49. list.concat(taicpu.op_none(A_FLDZ));
  50. end;
  51. procedure thlcgx86.a_jmp_external_name(list: TAsmList; const externalname: TSymStr);
  52. var
  53. ref : treference;
  54. sym : tasmsymbol;
  55. begin
  56. if (target_info.system = system_i386_darwin) then
  57. begin
  58. { a_jmp_name jumps to a stub which is always pic-safe on darwin }
  59. inherited;
  60. exit;
  61. end;
  62. sym:=current_asmdata.RefAsmSymbol(externalname,AT_FUNCTION);
  63. reference_reset_symbol(ref,sym,0,sizeof(pint),[]);
  64. { create pic'ed? }
  65. if (cs_create_pic in current_settings.moduleswitches) and
  66. { darwin/x86_64's assembler doesn't want @PLT after call symbols }
  67. not(target_info.system in [system_x86_64_darwin,system_i386_iphonesim,system_x86_64_iphonesim]) then
  68. ref.refaddr:=addr_pic
  69. else
  70. ref.refaddr:=addr_full;
  71. list.concat(taicpu.op_ref(A_JMP,S_NO,ref));
  72. end;
  73. procedure thlcgx86.a_load_undefined_cgpara(list: TAsmList; size: tdef; const cgpara: TCGPara);
  74. begin
  75. if not (cgpara.Location^.Loc in [LOC_REGISTER,LOC_CREGISTER]) and
  76. (cgpara.size=OS_ADDR) then
  77. a_load_reg_cgpara(list,size,NR_FRAME_POINTER_REG,cgpara)
  78. else
  79. inherited;
  80. end;
  81. end.