nllvmflw.pas 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. {
  2. Copyright (c) 2016 by Jonas Maebe
  3. Generate assembler for nodes that influence the flow for llvm
  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 nllvmflw;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. aasmbase,
  22. nflw, ncgflw, ncgnstfl;
  23. type
  24. tllvmlabelnode = class(tcglabelnode)
  25. function getasmlabel: tasmlabel; override;
  26. end;
  27. implementation
  28. {*****************************************************************************
  29. SecondLabel
  30. *****************************************************************************}
  31. uses
  32. aasmdata;
  33. function tllvmlabelnode.getasmlabel: tasmlabel;
  34. begin
  35. { don't allocate global labels even if the label is accessed from
  36. another routine: we always have to refer to such labels using the
  37. blockaddress() construct, which works with local labels too.
  38. Additionally, LLVM does not support defining global labels in the
  39. middle of a routine -> jumping to such a label from assembler code
  40. from another function will not work anyway (have to handle that by
  41. passing a blockaddress as argument to an assembler block, although
  42. "some targets may provide defined semantics when using the value as
  43. the operand to an inline assembly") }
  44. if not(assigned(asmlabel)) then
  45. current_asmdata.getjumplabel(asmlabel);
  46. result:=asmlabel
  47. end;
  48. begin
  49. clabelnode:=tllvmlabelnode;
  50. end.