tincexc.pp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : second_includeexclude() }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondcalln() }
  9. {****************************************************************}
  10. { DEFINES: }
  11. {****************************************************************}
  12. { REMARKS: Tests the include/exclude inline code generation. }
  13. {****************************************************************}
  14. program tincexc;
  15. {$mode objfpc}
  16. { Tests we must do :
  17. - small set : LOC_REGISTER, LOC_REFERENCE
  18. - large set : LOC_REFERENCE
  19. }
  20. procedure fail;
  21. begin
  22. WriteLn('Failed!');
  23. halt(1);
  24. end;
  25. type
  26. { DO NOT CHANGE THE VALUES OF THESE ENUMERATIONS! }
  27. tsmallenum = (dA,dB,dC,dd,de,df,dg,dh,di,dj,dk,dl,dm,dn,dop,dp,dq,dr);
  28. tasmop = (A_ABCD,
  29. A_ADD,A_ADDA,A_ADDI,A_ADDQ,A_ADDX,A_AND,A_ANDI,
  30. A_ASL,A_ASR,A_BCC,A_BCS,A_BEQ,A_BGE,A_BGT,A_BHI,
  31. A_BLE,A_BLS,A_BLT,A_BMI,A_BNE,A_BPL,A_BVC,A_BVS,
  32. A_BCHG,A_BCLR,A_BRA,A_BSET,A_BSR,A_BTST,A_CHK,
  33. A_CLR,A_CMP,A_CMPA,A_CMPI,A_CMPM,A_DBCC,A_DBCS,A_DBEQ,A_DBGE,
  34. A_DBGT,A_DBHI,A_DBLE,A_DBLS,A_DBLT,A_DBMI,A_DBNE,A_DBRA,
  35. A_DBPL,A_DBT,A_DBVC,A_DBVS,A_DBF,A_DIVS,A_DIVU,
  36. A_EOR,A_EORI,A_EXG,A_ILLEGAL,A_EXT,A_JMP,A_JSR,
  37. A_LEA,A_LINK,A_LSL,A_LSR,A_MOVE,A_MOVEA,A_MOVEI,A_MOVEQ,
  38. A_MOVEM,A_MOVEP,A_MULS,A_MULU,A_NBCD,A_NEG,A_NEGX,
  39. A_NOP,A_NOT,A_OR,A_ORI,A_PEA,A_ROL,A_ROR,A_ROXL,
  40. A_ROXR,A_RTR,A_RTS,A_SBCD,A_SCC,A_SCS,A_SEQ,A_SGE,
  41. A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,A_SNE,
  42. A_SPL,A_ST,A_SVC,A_SVS,A_SF,A_SUB,A_SUBA,A_SUBI,A_SUBQ,
  43. A_SUBX,A_SWAP,A_TAS,A_TRAP,A_TRAPV,A_TST,A_UNLK,
  44. A_RTE,A_RESET,A_STOP,
  45. { MC68010 instructions }
  46. A_BKPT,A_MOVEC,A_MOVES,A_RTD,
  47. { MC68020 instructions }
  48. A_BFCHG,A_BFCLR,A_BFEXTS,A_BFEXTU,A_BFFFO,
  49. A_BFINS,A_BFSET,A_BFTST,A_CALLM,A_CAS,A_CAS2,
  50. A_CHK2,A_CMP2,A_DIVSL,A_DIVUL,A_EXTB,A_PACK,A_RTM,
  51. A_TRAPCC,A_TRACS,A_TRAPEQ,A_TRAPF,A_TRAPGE,A_TRAPGT,
  52. A_TRAPHI,A_TRAPLE,A_TRAPLS,A_TRAPLT,A_TRAPMI,A_TRAPNE,
  53. A_TRAPPL,A_TRAPT,A_TRAPVC,A_TRAPVS,A_UNPK,
  54. { FPU Processor instructions - directly supported only. }
  55. { IEEE aware and misc. condition codes not supported }
  56. A_FABS,A_FADD,
  57. A_FBEQ,A_FBNE,A_FBNGT,A_FBGT,A_FBGE,A_FBNGE,
  58. A_FBLT,A_FBNLT,A_FBLE,A_FBGL,A_FBNGL,A_FBGLE,A_FBNGLE,
  59. A_FDBEQ,A_FDBNE,A_FDBGT,A_FDBNGT,A_FDBGE,A_FDBNGE,
  60. A_FDBLT,A_FDBNLT,A_FDBLE,A_FDBGL,A_FDBNGL,A_FDBGLE,A_FBDNGLE,
  61. A_FSEQ,A_FSNE,A_FSGT,A_FSNGT,A_FSGE,A_FSNGE,
  62. A_FSLT,A_FSNLT,A_FSLE,A_FSGL,A_FSNGL,A_FSGLE,A_FSNGLE,
  63. A_FCMP,A_FDIV,A_FMOVE,A_FMOVEM,
  64. A_FMUL,A_FNEG,A_FNOP,A_FSQRT,A_FSUB,A_FSGLDIV,
  65. A_FSFLMUL,A_FTST,
  66. A_FTRAPEQ,A_FTRAPNE,A_FTRAPGT,A_FTRAPNGT,A_FTRAPGE,A_FTRAPNGE,
  67. A_FTRAPLT,A_FTRAPNLT,A_FTRAPLE,A_FTRAPGL,A_FTRAPNGL,A_FTRAPGLE,A_FTRAPNGLE,
  68. { Protected instructions }
  69. A_CPRESTORE,A_CPSAVE,
  70. { FPU Unit protected instructions }
  71. { and 68030/68851 common MMU instructions }
  72. { (this may include 68040 MMU instructions) }
  73. A_FRESTORE,A_FSAVE,A_PFLUSH,A_PFLUSHA,A_PLOAD,A_PMOVE,A_PTEST,
  74. { Useful for assembly langage output }
  75. A_LABEL,A_NONE);
  76. type
  77. topset = set of tasmop;
  78. tsmallset = set of tsmallenum;
  79. procedure CheckPassed(passed:boolean);
  80. begin
  81. if passed then
  82. WriteLn('Success.')
  83. else
  84. begin
  85. WriteLn('Failure.');
  86. Halt(1);
  87. end;
  88. end;
  89. Procedure SetTestIncludeOne;
  90. var
  91. op : tasmop;
  92. oplist: set of tasmop;
  93. Begin
  94. Write('Include Large Set element testing (LOC_REFERENCE/LOC_REFERENCE)...');
  95. op:=A_LABEL;
  96. oplist:=[];
  97. Include(oplist, op);
  98. CheckPassed(oplist = [A_LABEL]);
  99. end;
  100. function get_large_enum : tasmop;
  101. begin
  102. get_large_enum := A_LABEL;
  103. end;
  104. Procedure SetTestIncludeTwo;
  105. var
  106. oplist: set of tasmop;
  107. Begin
  108. Write('Include Large Set element testing (LOC_REFERENCE/LOC_REGISTER)...');
  109. oplist:=[];
  110. Include(oplist, get_large_enum);
  111. CheckPassed(oplist = [A_LABEL]);
  112. end;
  113. Procedure SetTestIncludeThree;
  114. var
  115. small_enum : tsmallenum;
  116. small_set : set of tsmallenum;
  117. begin
  118. Write('Include Small Set element testing (LOC_REFERENCE/LOC_REFERENCE)...');
  119. small_enum := dop;
  120. small_set := [];
  121. Include(small_set, small_enum);
  122. CheckPassed(small_set = [DOP]);
  123. end;
  124. function get_small_enum : tsmallenum;
  125. begin
  126. get_small_enum := dop;
  127. end;
  128. Procedure SetTestIncludeFour;
  129. var
  130. small_enum : tsmallenum;
  131. small_set : set of tsmallenum;
  132. begin
  133. Write('Include Small Set element testing (LOC_REFERENCE/LOC_REGISTER)...');
  134. small_enum := dop;
  135. small_set := [];
  136. Include(small_set, get_small_enum);
  137. CheckPassed(small_set = [DOP]);
  138. end;
  139. Procedure SetTestExcludeOne;
  140. var
  141. op : tasmop;
  142. oplist: set of tasmop;
  143. Begin
  144. Write('Exclude Large Set element testing (LOC_REFERENCE/LOC_REFERENCE)...');
  145. op:=A_RTE;
  146. oplist:=[A_RTE,A_LABEL,A_STOP];
  147. Exclude(oplist, op);
  148. CheckPassed(oplist = [A_LABEL,A_STOP]);
  149. end;
  150. Procedure SetTestExcludeTwo;
  151. var
  152. small_enum : tsmallenum;
  153. small_set : set of tsmallenum;
  154. begin
  155. Write('Exclude Small Set element testing (LOC_REFERENCE/LOC_REFERENCE)...');
  156. small_enum := dop;
  157. small_set := [dc,dop,dp,dq,dm];
  158. Exclude(small_set, small_enum);
  159. CheckPassed(small_set = [dc,dp,dq,dm]);
  160. end;
  161. function get_small_enum_two : tsmallenum;
  162. begin
  163. get_small_enum_two := dop;
  164. end;
  165. Procedure SetTestExcludeThree;
  166. var
  167. small_set : set of tsmallenum;
  168. begin
  169. Write('Exclude Small Set element testing (LOC_REFERENCE/LOC_REGISTER)...');
  170. small_set := [dc,dop,dp,dq,dm];
  171. Exclude(small_set, get_small_enum);
  172. CheckPassed(small_set = [dc,dp,dq,dm]);
  173. end;
  174. function get_large_enum_two : tasmop;
  175. begin
  176. get_large_enum_two := A_LABEL;
  177. end;
  178. Procedure SetTestExcludeFour;
  179. var
  180. oplist: set of tasmop;
  181. Begin
  182. Write('Exclude Large Set element testing (LOC_REFERENCE/LOC_REGISTER)...');
  183. oplist:=[A_LABEL,A_STOP];
  184. Exclude(oplist, get_large_enum_two);
  185. CheckPassed(oplist = [A_STOP]);
  186. end;
  187. Begin
  188. SetTestIncludeOne;
  189. SetTestIncludeTwo;
  190. SetTestIncludeThree;
  191. SetTestIncludeFour;
  192. SetTestExcludeOne;
  193. SetTestExcludeTwo;
  194. SetTestExcludeThree;
  195. SetTestExcludeFour;
  196. end.
  197. {
  198. $Log$
  199. Revision 1.2 2002-09-07 15:40:56 peter
  200. * old logs removed and tabs fixed
  201. Revision 1.1 2002/07/25 17:52:59 carl
  202. + include / exclude inline node testing
  203. }