Esempio n. 1
0
void genSetWriteStride(Seq<Instr>* instrs, int stride)
{
  int strideBytes = stride*4;
  assert(strideBytes < 8192);
  int setup = 0xc0010000 | strideBytes;
  Reg dst; dst.tag = REG_A; dst.regId = RSV_WRITE_STRIDE;
  Instr instr = genLI(dst, setup);
  instrs->append(instr);
}
Esempio n. 2
0
void genSetReadStride(Seq<Instr>* instrs, int stride)
{
  int pitch = (stride+1)*4;
  assert(pitch < 8192);
  int setup = 0x90000000 | pitch;
  Reg dst; dst.tag = REG_A; dst.regId = RSV_READ_STRIDE;
  Instr instr = genLI(dst, setup);
  instrs->append(instr);
}
Esempio n. 3
0
void compileForSt(void) {
  CodeAddress beginLoop;
  Instruction* fjInstruction;
  Type* varType;
  Type *type;

  eat(KW_FOR);

  varType = compileLValue();
  eat(SB_ASSIGN);

  genCV();
  type = compileExpression();
  checkTypeEquality(varType, type);
  genST();
  genCV();
  genLI();
  beginLoop = getCurrentCodeAddress();
  eat(KW_TO);

  type = compileExpression();
  checkTypeEquality(varType, type);
  genLE();
  fjInstruction = genFJ(DC_VALUE);

  eat(KW_DO);
  compileStatement();

  genCV();  
  genCV();
  genLI();
  genLC(1);
  genAD();
  genST();

  genCV();
  genLI();

  genJ(beginLoop);
  updateFJ(fjInstruction, getCurrentCodeAddress());
  genDCT(1);

}
Esempio n. 4
0
void assignVPMLoadSetup(Seq<Instr>* instrs, Reg dst, BufferAorB b, Reg qpuId)
{
  int setup = 0x00100200;
  int buffIdx = (b == A ? 0 : 1) << 4;
  setup |= buffIdx;

  Reg tmp = freshReg();
  instrs->append(genLI(tmp, setup));
  instrs->append(genOR(dst, qpuId, tmp));
}
Esempio n. 5
0
void genSetWriteStride(Seq<Instr>* instrs, Reg stride)
{
  Reg tmp0 = freshReg();
  Reg tmp1 = freshReg();
  instrs->append(genLShift(tmp0, stride, 2));
  instrs->append(genLI(tmp1, 0xc0010000));

  Reg dst; dst.tag = REG_A; dst.regId = RSV_WRITE_STRIDE;
  instrs->append(genOR(dst, tmp0, tmp1));
}
Esempio n. 6
0
void genSetReadStride(Seq<Instr>* instrs, Reg stride)
{
  Reg pitch = freshReg();
  Reg tmp = freshReg();
  instrs->append(genIncr(pitch, stride, 1));
  instrs->append(genLI(tmp, 0x90000000));
  instrs->append(genLShift(pitch, pitch, 2));

  Reg dst; dst.tag = REG_A; dst.regId = RSV_READ_STRIDE;
  instrs->append(genOR(dst, tmp, pitch));
}
Esempio n. 7
0
void assignDMAStoreSetup(Seq<Instr>* instrs, Reg dst, BufferAorB b, Reg qpuId)
{
  int setup = 0x88014000;
  int buffIdx = (16 * (b == A ? 2 : 3)) << 7;
  setup |= buffIdx;

  Reg tmp0 = freshReg();
  instrs->append(genLI(tmp0, setup));

  Reg tmp1 = freshReg();
  instrs->append(genLShift(tmp1, qpuId, 3));

  instrs->append(genOR(dst, tmp0, tmp1));
}
Esempio n. 8
0
void genSetupVPMStore(Seq<Instr>* instrs, BufferAorB b, Reg qpuId)
{
  int setup = 0x00100200;
  int buffIdx = (b == A ? 2 : 3) << 4;
  setup |= buffIdx;

  Reg tmp = freshReg();
  instrs->append(genLI(tmp, setup));

  Reg dst;
  dst.tag   = SPECIAL;
  dst.regId = SPECIAL_WR_SETUP;
  instrs->append(genOR(dst, qpuId, tmp));
}
Esempio n. 9
0
Type* compileFactor(void) {
  Type* type;
  Object* obj;

  switch (lookAhead->tokenType) {
  case TK_NUMBER:
    eat(TK_NUMBER);
    type = intType;
    genLC(currentToken->value);
    break;
  case TK_CHAR:
    eat(TK_CHAR);
    type = charType;
    genLC(currentToken->value);
    break;
  case TK_IDENT:
    eat(TK_IDENT);
    obj = checkDeclaredIdent(currentToken->string);

    switch (obj->kind) {
    case OBJ_CONSTANT:
      switch (obj->constAttrs->value->type) {
      case TP_INT:
	type = intType;
	genLC(obj->constAttrs->value->intValue);
	break;
      case TP_CHAR:
	type = charType;
	genLC(obj->constAttrs->value->charValue);
	break;
      default:
	break;
      }
      break;
    case OBJ_VARIABLE:
      if (obj->varAttrs->type->typeClass == TP_ARRAY) {
	genVariableAddress(obj);
	type = compileIndexes(obj->varAttrs->type);
	genLI();
      } else {
	type = obj->varAttrs->type;
	genVariableValue(obj);
      }
      break;
    case OBJ_PARAMETER:
      // TODO: push parameter's value onto the stack
      type = obj->paramAttrs->type;
      break;
    case OBJ_FUNCTION:
      // TODO: generate function call
      if (isPredefinedFunction(obj)) {
	compileArguments(obj->funcAttrs->paramList);
	genPredefinedFunctionCall(obj);
      } else {
	compileArguments(obj->funcAttrs->paramList);
      }
      type = obj->funcAttrs->returnType;
      break;
    default: 
      error(ERR_INVALID_FACTOR,currentToken->lineNo, currentToken->colNo);
      break;
    }
    break;
  case SB_LPAR:
    eat(SB_LPAR);
    type = compileExpression();
    eat(SB_RPAR);
    break;
  default:
    error(ERR_INVALID_FACTOR, lookAhead->lineNo, lookAhead->colNo);
  }
  
  return type;
}