dcc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. } OPTION;
  38. extern OPTION option; /* Command line options */
  39. #include "BinaryImage.h"
  40. /* Memory map states */
  41. enum eAreaType
  42. {
  43. BM_UNKNOWN = 0, /* Unscanned memory */
  44. BM_DATA = 1, /* Data */
  45. BM_CODE = 2, /* Code */
  46. BM_IMPURE = 3 /* Used as Data and Code*/
  47. };
  48. /* Intermediate instructions statistics */
  49. struct STATS
  50. {
  51. int numBBbef; /* number of basic blocks initially */
  52. int numBBaft; /* number of basic blocks at the end */
  53. int nOrder; /* n-th order */
  54. int numLLIcode; /* number of low-level Icode instructions */
  55. int numHLIcode; /* number of high-level Icode instructions */
  56. int totalLL; /* total number of low-level Icode insts */
  57. int totalHL; /* total number of high-level Icod insts */
  58. };
  59. extern STATS stats; /* Icode statistics */
  60. /**** Global function prototypes ****/
  61. void udm(void); /* udm.c */
  62. void freeCFG(BB * cfg); /* graph.c */
  63. BB * newBB(BB *, int, int, uint8_t, int, Function *); /* graph.c */
  64. void BackEnd(CALL_GRAPH *); /* backend.c */
  65. extern char *cChar(uint8_t c); /* backend.c */
  66. eErrorId scan(uint32_t ip, ICODE &p); /* scanner.c */
  67. void parse (CALL_GRAPH * *); /* parser.c */
  68. extern int strSize (const uint8_t *, char); /* parser.c */
  69. //void disassem(int pass, Function * pProc); /* disassem.c */
  70. void interactDis(Function *, int initIC); /* disassem.c */
  71. bool JmpInst(llIcode opcode); /* idioms.c */
  72. queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
  73. void SetupLibCheck(void); /* chklib.c */
  74. void CleanupLibCheck(void); /* chklib.c */
  75. bool LibCheck(Function &p); /* chklib.c */
  76. /* Exported functions from hlicode.c */
  77. const char *writeJcond(const HLTYPE &, Function *, int *);
  78. const char *writeJcondInv (HLTYPE, Function *, int *);
  79. /* Exported funcions from locident.c */
  80. bool checkLongEq(LONG_STKID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &atOffset);
  81. bool checkLongRegEq(LONGID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &);
  82. eReg otherLongRegi(eReg, int, LOCAL_ID *);
  83. extern const char *indentStr(int level);