nllvmmat.pas 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {
  2. Copyright (c) 2014 Jonas Maebe
  3. Generate LLVM IR for math nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit nllvmmat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symtype,
  22. node, nmat, ncgmat, cgbase;
  23. type
  24. Tllvmunaryminusnode = class(tcgunaryminusnode)
  25. procedure emit_float_sign_change(r: tregister; _size : tdef);override;
  26. end;
  27. implementation
  28. uses
  29. globtype, systems,
  30. cutils, verbose, globals,
  31. symconst, symdef,
  32. aasmbase, aasmllvm, aasmtai, aasmdata,
  33. defutil,
  34. procinfo,
  35. hlcgobj, pass_2,
  36. ncon,
  37. llvmbase,
  38. ncgutil, cgutils;
  39. {*****************************************************************************
  40. Tllvmunaryminusnode
  41. *****************************************************************************}
  42. procedure Tllvmunaryminusnode.emit_float_sign_change(r: tregister; _size : tdef);
  43. var
  44. zeroreg: tregister;
  45. begin
  46. if _size.typ<>floatdef then
  47. internalerror(2014012212);
  48. zeroreg:=hlcg.getfpuregister(current_asmdata.CurrAsmList,_size);
  49. case tfloatdef(_size).floattype of
  50. s32real,s64real:
  51. current_asmdata.CurrAsmList.concat(taillvm.op_reg_size_fpconst_size(la_bitcast,zeroreg,_size,0,_size));
  52. { comp and currency are handled as int64 at the llvm level }
  53. s64comp,
  54. s64currency:
  55. { sc80floattype instead of _size, see comment in thlcgllvm.a_loadfpu_ref_reg }
  56. current_asmdata.CurrAsmList.concat(taillvm.op_reg_size_const_size(la_sitofp,zeroreg,s64inttype,0,sc80floattype));
  57. {$ifdef cpuextended}
  58. s80real,sc80real:
  59. current_asmdata.CurrAsmList.concat(taillvm.op_reg_size_fpconst80_size(la_bitcast,zeroreg,_size,0.0,_size));
  60. {$endif cpuextended}
  61. end;
  62. current_asmdata.CurrAsmList.Concat(taillvm.op_reg_size_reg_reg(la_fsub,r,_size,zeroreg,r));
  63. end;
  64. begin
  65. (*
  66. cmoddivnode := tllvmmoddivnode;
  67. cshlshrnode := tllvmshlshrnode;
  68. cnotnode := tllvmnotnode;
  69. *)
  70. cunaryminusnode := Tllvmunaryminusnode;
  71. end.