⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operationselection.java

📁 一种将c高级语言转化给VHDL的编译器
💻 JAVA
字号:
/* * LA-CC 05-135 Trident 0.7.1Copyright NoticeCopyright 2006 (c) the Regents of the University of California.This Software was produced under a U.S. Government contract(W-7405-ENG-36) by Los Alamos National Laboratory, which is operatedby the University of California for the U.S. Department of Energy. TheU.S. Government is licensed to use, reproduce, and distribute thisSoftware. Permission is granted to the public to copy and use thisSoftware without charge, provided that this Notice and any statementof authorship are reproduced on all copies. Neither the Government northe University makes any warranty, express or implied, or assumes anyliability or responsibility for the user of this Software. */package fp.passes;import java.util.*;import fp.GlobalOptions;import fp.flowgraph.*;import fp.util.BooleanEquation;import fp.util.UseHash;public class OperationSelection extends Pass implements BlockPass, Operators {    public OperationSelection(PassManager pm) {    super(pm);  }  public String name() { return "OperationSelection"; }  /*    Some discussion:    I don't think that it makes sense in general to have "library" versions of     aload and astore.  These depend on two different things: 1) the target board    in question and 2) whether we should map a particular array to block ram or    to external ram.  */  public boolean optimize(BlockNode node) {        ArrayList list = node.getInstructions();    for(Iterator iter = list.iterator(); iter.hasNext(); ) {      Instruction instruction = (Instruction)iter.next();      select(instruction);    }    return true;  }	  // need to fix the NOPs and make them exceptions...  public void select(Instruction instruction) {    if(ALoad.conforms(instruction)) {      if(GlobalOptions.chipDef.chooseLoadOp(instruction)==null)        instruction.operator = AAA_ALOAD;      else        instruction.operator = GlobalOptions.chipDef.chooseLoadOp(instruction);    }    if(AStore.conforms(instruction)) {      if(GlobalOptions.chipDef.chooseStoreOp(instruction)==null)        instruction.operator = AAA_ASTORE;      else        instruction.operator = GlobalOptions.chipDef.chooseStoreOp(instruction);    }    switch(instruction.operator.opcode) {      // type independant.    case ALOAD_opcode:      /* this is only for block ram array load and not for 	 external rams.  External loads will need to be in their	 actual fpga board library (e.g., XD1_ALOAD or OSIRIS_ALOAD ... )      */      //if(GlobalOptions.hardwareName == GlobalOptions.XD1_HW)	//instruction.operator = XD1_ALOAD;      //else	//instruction.operator = AAA_ALOAD;	if(GlobalOptions.chipDef.chooseLoadOp(instruction)==null)	  instruction.operator = AAA_ALOAD;        else	  instruction.operator = GlobalOptions.chipDef.chooseLoadOp(instruction);      break;    case ASTORE_opcode:      //if(GlobalOptions.hardwareName == GlobalOptions.XD1_HW)	//instruction.operator = XD1_ASTORE;      //else	//instruction.operator = AAA_ASTORE;	if(GlobalOptions.chipDef.chooseStoreOp(instruction)==null)	  instruction.operator = AAA_ASTORE;	else	  instruction.operator = GlobalOptions.chipDef.chooseStoreOp(instruction);      break;    case LOAD_opcode:      instruction.operator = AAA_LOAD;      break;    case STORE_opcode:      instruction.operator = AAA_STORE;      break;    case SELECT_opcode:      instruction.operator = AAA_SELECT;      break;    case AND_opcode:      instruction.operator = AAA_AND;      break;    case OR_opcode:      instruction.operator = AAA_OR;      break;    case XOR_opcode:      instruction.operator = AAA_XOR;      break;    case NOT_opcode:      instruction.operator = AAA_NOT;      break;    case SETEQ_opcode:      instruction.operator = AAA_SETEQ;      break;    case SETNE_opcode:      instruction.operator = AAA_SETNE;      break;    case SETLT_opcode:      instruction.operator = AAA_SETLT;      break;    case SETGT_opcode:      instruction.operator = AAA_SETGT;      break;    case SETLE_opcode:      instruction.operator = AAA_SETLE;      break;    case SETGE_opcode:      instruction.operator = AAA_SETGE;      break;    case SHR_opcode:      if (Shift.getVal2(instruction).isConstant())	  instruction.operator = AAA_CSHR;      else	instruction.operator = AAA_SHR;	break;    case SHL_opcode:      if (Shift.getVal2(instruction).isConstant())	instruction.operator = AAA_CSHL;      else	instruction.operator = AAA_SHL;      break;    case ADD_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_IADD;      break;    case SUB_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_ISUB;      break;    case MUL_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_IMUL;      break;    case DIV_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_IDIV;      break;    case INV_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_IINV;      break;    case SQRT_opcode:      if (instruction.type().isFloat()) 	instruction.operator = NOP;      else 	instruction.operator = AAA_ISQRT;      break;    default:      System.err.println("OperationSelection: I do not handle selecting operand "+instruction.operator);    }  }	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -