narmcnv.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate ARM assembler for type converting nodes
  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. unit narmcnv;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ncnv,ncgcnv,defcmp;
  23. type
  24. tarmtypeconvnode = class(tcgtypeconvnode)
  25. protected
  26. function first_int_to_real: tnode;override;
  27. { procedure second_int_to_int;override; }
  28. { procedure second_string_to_string;override; }
  29. { procedure second_cstring_to_pchar;override; }
  30. { procedure second_string_to_chararray;override; }
  31. { procedure second_array_to_pointer;override; }
  32. // function first_int_to_real: tnode; override;
  33. { procedure second_pointer_to_array;override; }
  34. { procedure second_chararray_to_string;override; }
  35. { procedure second_char_to_string;override; }
  36. procedure second_int_to_real;override;
  37. // procedure second_real_to_real;override;
  38. { procedure second_cord_to_pointer;override; }
  39. { procedure second_proc_to_procvar;override; }
  40. { procedure second_bool_to_int;override; }
  41. procedure second_int_to_bool;override;
  42. { procedure second_load_smallset;override; }
  43. { procedure second_ansistring_to_pchar;override; }
  44. { procedure second_pchar_to_string;override; }
  45. { procedure second_class_to_intf;override; }
  46. { procedure second_char_to_char;override; }
  47. end;
  48. implementation
  49. uses
  50. verbose,globals,systems,
  51. symconst,symdef,aasmbase,aasmtai,
  52. defutil,
  53. cgbase,pass_1,pass_2,
  54. ncon,ncal,
  55. ncgutil,
  56. cpubase,aasmcpu,
  57. rgobj,tgobj,cgobj;
  58. {*****************************************************************************
  59. FirstTypeConv
  60. *****************************************************************************}
  61. function tarmtypeconvnode.first_int_to_real: tnode;
  62. var
  63. fname: string[19];
  64. begin
  65. { converting a 64bit integer to a float requires a helper }
  66. if is_64bitint(left.resulttype.def) then
  67. begin
  68. if is_signed(left.resulttype.def) then
  69. fname := 'fpc_int64_to_double'
  70. else
  71. fname := 'fpc_qword_to_double';
  72. result := ccallnode.createintern(fname,ccallparanode.create(
  73. left,nil));
  74. left:=nil;
  75. firstpass(result);
  76. exit;
  77. end
  78. else
  79. { other integers are supposed to be 32 bit }
  80. begin
  81. if is_signed(left.resulttype.def) then
  82. inserttypeconv(left,s32bittype)
  83. else
  84. inserttypeconv(left,u32bittype);
  85. firstpass(left);
  86. end;
  87. result := nil;
  88. if registersfpu<1 then
  89. registersfpu:=1;
  90. expectloc:=LOC_FPUREGISTER;
  91. end;
  92. procedure tarmtypeconvnode.second_int_to_real;
  93. var
  94. instr : taicpu;
  95. begin
  96. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  97. location_force_reg(exprasmlist,left.location,OS_32,true);
  98. location.register:=cg.getfpuregister(exprasmlist,location.size);
  99. instr:=taicpu.op_reg_reg(A_FLT,location.register,left.location.register);
  100. instr.oppostfix:=cgsize2fpuoppostfix[def_cgsize(resulttype.def)];
  101. exprasmlist.concat(instr);
  102. end;
  103. procedure tarmtypeconvnode.second_int_to_bool;
  104. begin
  105. end;
  106. begin
  107. ctypeconvnode:=tarmtypeconvnode;
  108. end.
  109. {
  110. $Log$
  111. Revision 1.6 2003-11-04 22:30:15 florian
  112. + type cast variant<->enum
  113. * cnv. node second pass uses now as well helper wrappers
  114. Revision 1.5 2003/11/02 14:30:03 florian
  115. * fixed ARM for new reg. allocation scheme
  116. Revision 1.4 2003/09/01 15:11:16 florian
  117. * fixed reference handling
  118. * fixed operand postfix for floating point instructions
  119. * fixed wrong shifter constant handling
  120. Revision 1.3 2003/09/01 09:54:57 florian
  121. * results of work on arm port last weekend
  122. Revision 1.2 2003/08/25 23:20:38 florian
  123. + started to implement FPU support for the ARM
  124. * fixed a lot of other things
  125. Revision 1.1 2003/08/21 23:24:08 florian
  126. * continued to work on the arm skeleton
  127. }