cgutils.pas 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {
  2. $Id$
  3. Copyright (c) 1998-2004 by Florian Klaempfl
  4. Some basic types and constants for the code generation
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. { This unit exports some helper routines which are used across the code generator }
  19. unit cgutils;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. aasmbase,
  24. cgbase,
  25. cpubase;
  26. { trerefence handling }
  27. {# Clear to zero a treference }
  28. procedure reference_reset(var ref : treference);
  29. {# Clear to zero a treference, and set is base address
  30. to base register.
  31. }
  32. procedure reference_reset_base(var ref : treference;base : tregister;offset : longint);
  33. procedure reference_reset_symbol(var ref : treference;sym : tasmsymbol;offset : longint);
  34. { This routine verifies if two references are the same, and
  35. if so, returns TRUE, otherwise returns false.
  36. }
  37. function references_equal(sref : treference;dref : treference) : boolean;
  38. implementation
  39. {****************************************************************************
  40. TReference
  41. ****************************************************************************}
  42. procedure reference_reset(var ref : treference);
  43. begin
  44. FillChar(ref,sizeof(treference),0);
  45. {$ifdef arm}
  46. ref.signindex:=1;
  47. {$endif arm}
  48. end;
  49. procedure reference_reset_base(var ref : treference;base : tregister;offset : longint);
  50. begin
  51. reference_reset(ref);
  52. ref.base:=base;
  53. ref.offset:=offset;
  54. end;
  55. procedure reference_reset_symbol(var ref : treference;sym : tasmsymbol;offset : longint);
  56. begin
  57. reference_reset(ref);
  58. ref.symbol:=sym;
  59. ref.offset:=offset;
  60. end;
  61. function references_equal(sref : treference;dref : treference):boolean;
  62. begin
  63. references_equal:=CompareByte(sref,dref,sizeof(treference))=0;
  64. end;
  65. end.
  66. {
  67. $Log$
  68. Revision 1.1 2004-02-27 10:21:05 florian
  69. * top_symbol killed
  70. + refaddr to treference added
  71. + refsymbol to treference added
  72. * top_local stuff moved to an extra record to save memory
  73. + aint introduced
  74. * tppufile.get/putint64/aint implemented
  75. }