dcc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /****************************************************************************
  2. * dcc project general header
  3. * (C) Cristina Cifuentes, Mike van Emmerik
  4. ****************************************************************************/
  5. #pragma once
  6. //TODO: Remove boolT
  7. #include <llvm/ADT/ilist.h>
  8. #include <utility>
  9. #include <algorithm>
  10. #include <bitset>
  11. #include <QtCore/QString>
  12. #include "Enums.h"
  13. #include "types.h"
  14. #include "ast.h"
  15. #include "icode.h"
  16. #include "locident.h"
  17. #include "error.h"
  18. #include "graph.h"
  19. #include "bundle.h"
  20. #include "Procedure.h"
  21. #include "BasicBlock.h"
  22. class Project;
  23. /* CALL GRAPH NODE */
  24. extern bundle cCode; /* Output C procedure's declaration and code */
  25. /**** Global variables ****/
  26. extern QString asm1_name, asm2_name; /* Assembler output filenames */
  27. typedef struct { /* Command line option flags */
  28. unsigned verbose : 1;
  29. unsigned VeryVerbose : 1;
  30. unsigned asm1 : 1; /* Early disassembly listing */
  31. unsigned asm2 : 1; /* Disassembly listing after restruct */
  32. unsigned Map : 1;
  33. unsigned Stats : 1;
  34. unsigned Interact : 1; /* Interactive mode */
  35. unsigned Calls : 1; /* Follow register indirect calls */
  36. QString filename; /* The input filename */
  37. uint32_t CustomEntryPoint;
  38. } OPTION;
  39. extern OPTION option; /* Command line options */
  40. #include "BinaryImage.h"
  41. /* Memory map states */
  42. enum eAreaType
  43. {
  44. BM_UNKNOWN = 0, /* Unscanned memory */
  45. BM_DATA = 1, /* Data */
  46. BM_CODE = 2, /* Code */
  47. BM_IMPURE = 3 /* Used as Data and Code*/
  48. };
  49. /* Intermediate instructions statistics */
  50. struct STATS
  51. {
  52. int numBBbef; /* number of basic blocks initially */
  53. int numBBaft; /* number of basic blocks at the end */
  54. int nOrder; /* n-th order */
  55. int numLLIcode; /* number of low-level Icode instructions */
  56. int numHLIcode; /* number of high-level Icode instructions */
  57. int totalLL; /* total number of low-level Icode insts */
  58. int totalHL; /* total number of high-level Icod insts */
  59. };
  60. extern STATS stats; /* Icode statistics */
  61. /**** Global function prototypes ****/
  62. void udm(void); /* udm.c */
  63. void freeCFG(BB * cfg); /* graph.c */
  64. BB * newBB(BB *, int, int, uint8_t, int, Function *); /* graph.c */
  65. void BackEnd(CALL_GRAPH *); /* backend.c */
  66. extern char *cChar(uint8_t c); /* backend.c */
  67. eErrorId scan(uint32_t ip, ICODE &p); /* scanner.c */
  68. void parse (CALL_GRAPH * *); /* parser.c */
  69. extern int strSize (const uint8_t *, char); /* parser.c */
  70. //void disassem(int pass, Function * pProc); /* disassem.c */
  71. void interactDis(Function *, int initIC); /* disassem.c */
  72. bool JmpInst(llIcode opcode); /* idioms.c */
  73. queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
  74. bool SetupLibCheck(void); /* chklib.c */
  75. void CleanupLibCheck(void); /* chklib.c */
  76. bool LibCheck(Function &p); /* chklib.c */
  77. /* Exported functions from hlicode.c */
  78. QString writeJcond(const HLTYPE &, Function *, int *);
  79. QString writeJcondInv(HLTYPE, Function *, int *);
  80. /* Exported funcions from locident.c */
  81. bool checkLongEq(LONG_STKID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &atOffset);
  82. bool checkLongRegEq(LONGID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &);
  83. eReg otherLongRegi(eReg, int, LOCAL_ID *);
  84. extern const char *indentStr(int level);