llvmpi.pas 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {
  2. Copyright (c) 2016 by Jonas Maebe
  3. Information about the current procedure that is being compiled
  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 llvmpi;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. aasmbase,
  23. procinfo,
  24. cpupi;
  25. type
  26. tllvmprocinfo = class(tcpuprocinfo)
  27. private
  28. fexceptlabelstack: tfplist;
  29. public
  30. constructor create(aparent: tprocinfo); override;
  31. destructor destroy; override;
  32. procedure pushexceptlabel(lab: TAsmLabel);
  33. procedure popexceptlabel(lab: TAsmLabel);
  34. function CurrExceptLabel: TAsmLabel; inline;
  35. end;
  36. implementation
  37. uses
  38. globtype,verbose,systems,
  39. symtable;
  40. constructor tllvmprocinfo.create(aparent: tprocinfo);
  41. begin
  42. inherited;
  43. fexceptlabelstack:=tfplist.create;
  44. end;
  45. destructor tllvmprocinfo.destroy;
  46. begin
  47. if fexceptlabelstack.Count<>0 then
  48. Internalerror(2016121301);
  49. fexceptlabelstack.free;
  50. inherited;
  51. end;
  52. procedure tllvmprocinfo.pushexceptlabel(lab: TAsmLabel);
  53. begin
  54. fexceptlabelstack.add(lab);
  55. end;
  56. procedure tllvmprocinfo.popexceptlabel(lab: TAsmLabel);
  57. begin
  58. if CurrExceptLabel<>lab then
  59. internalerror(2016121302);
  60. fexceptlabelstack.count:=fexceptlabelstack.count-1;
  61. end;
  62. function tllvmprocinfo.CurrExceptLabel: TAsmLabel; inline;
  63. begin
  64. result:=TAsmLabel(fexceptlabelstack.last);
  65. if not assigned(result) then
  66. internalerror(2016121703);
  67. end;
  68. begin
  69. if not assigned(cprocinfo) then
  70. begin
  71. writeln('Internalerror 2018052005');
  72. halt(1);
  73. end;
  74. cprocinfo:=tllvmprocinfo;
  75. end.