IVANNOSYS.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package compiler;
  2. /*
  3. Verificar operacao unaria negacao valor em laco
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8. import API.Api;
  9. import API.BuildParams;
  10. import API.CodeProcessor;
  11. import API.Target;
  12. import IntermediaryCode.IRGenerator;
  13. import java.util.logging.Level;
  14. import java.util.logging.Logger;
  15. /**
  16. *
  17. * @author Eugenio
  18. */
  19. public class IVANNOSYS {
  20. protected static IvannosysCompiler COM;
  21. /**
  22. * @param args the command line arguments
  23. */
  24. public static void main(String[] args) throws Exception {
  25. try {
  26. String cmd = "", file = "";
  27. if (args.length
  28. > 0) {
  29. cmd = args[0];
  30. }
  31. switch (cmd) {
  32. case "create":
  33. break;
  34. default:
  35. COM = new IvannosysCompiler(
  36. "UTF-8",
  37. IvannosysCompiler.INPUT_FILE)
  38. .include(".\\src\\samples")
  39. // Especifica a classe de geração de codigo de tres enderecos
  40. .IRGenerator(new IRGenerator())
  41. // Extensao dos arquivos
  42. .setExtensionLibrary(".go");
  43. // Inicializa a api do compilador
  44. Api.Init(COM);
  45. // Parametros de compilação
  46. BuildParams.Add("display.ERROS", "true");
  47. BuildParams.Add("display.IR", "true");
  48. BuildParams.Add("display.AST", "true");
  49. BuildParams.Add("mode", "developement");
  50. // Especifica a classe de geração de codigo alvo mips
  51. Target.Add("mips", new targets.mips.Gen());
  52. Target.Add("mipsjun", new targets.mips.jun.Gen());
  53. // Registra os processadores para o alvo mips
  54. // Executa alocacao de registradores antes de traduzir cada bloco
  55. CodeProcessor.On("mips,mipsjun", "BeforeTranslateBlock", "mips.register.alloc");
  56. CodeProcessor.On("mips,mipsjun", "AfterTranslateBlock", "mips.o.L1,mips.copy.dep");
  57. // Atualiza os enderecos
  58. CodeProcessor.On("mips,mipsjun", "AfterTranslate", "mips.update.address");
  59. // String file = "src\\samples\\program.go",
  60. // String file = "src\\samples\\program.go",
  61. // String file = "src\\samples\\program_mult_manycore.go",
  62. // String file = "src\\samples\\program_mult_jon.go",
  63. // String file = "src\\samples\\program_mult.go",
  64. file = "src\\samples\\program_jun_bit_count.go";
  65. COM.Compile(file);
  66. }
  67. } catch (Exception ex) {
  68. Logger.getLogger(IVANNOSYS.class.getName()).log(Level.SEVERE, null, ex);
  69. }
  70. }
  71. }