Exemplo n.º 1
0
void SPARCSignature::getLibraryDefines(StatementList &defs)
{
    if (defs.size() > 0) {
        return; // Do only once
    }

    // o0-o7 (r8-r15) modified
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O0)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O1)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O2)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O3)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O4)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O5)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O6)));
    defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O7)));
}
Exemplo n.º 2
0
// Return a list of locations defined by library calls
void PPCSignature::getLibraryDefines(StatementList &defs)
{
    if (defs.size() > 0) {
        return; // Do only once
    }

    for (int r = REG_PPC_G3; r <= REG_PPC_G12; ++r) {
        defs.append(
            new ImplicitAssign(Location::regOf(r))); // Registers 3-12 are volatile (caller save)
    }
}
Exemplo n.º 3
0
void RtlTest::testSetConscripts()
{
  // m[1000] = m[1000] + 1000
  Statement* s1 = new Assign(
                    Location::memOf(
                      new Const(1000), 0),
                    new Binary(opPlus,
                               Location::memOf(
                                 new Const(1000), NULL),
                               new Const(1000)));

  // "printf("max is %d", (local0 > 0) ? local0 : global1)
  CallStatement* s2 = new CallStatement();
  std::string name("printf");
  Proc* proc = new UserProc(new Prog(), name, 0x2000);	// Making a true LibProc is problematic
  s2->setDestProc(proc);
  s2->setCalleeReturn(new ReturnStatement);		// So it's not a childless call
  Exp* e1 = new Const("max is %d");
  Exp* e2 = new Ternary(opTern,
                        new Binary(opGtr,
                                   Location::local("local0", NULL),
                                   new Const(0)),
                        Location::local("local0", NULL),
                        Location::global("global1", NULL));
  StatementList args;
  args.append(new Assign(Location::regOf(8), e1));
  args.append(new Assign(Location::regOf(9), e2));
  s2->setArguments(args);

  std::list<Statement*> list;
  list.push_back(s1);
  list.push_back(s2);
  RTL* rtl = new RTL(0x1000, &list);
  rtl->setConscripts(0, false);
  std::string expected(
    "00001000    0 *v* m[1000\\1\\] := m[1000\\2\\] + 1000\\3\\\n"
    "            0 CALL printf(\n"
    "                *v* r8 := \"max is %d\"\\4\\\n"
    "                *v* r9 := (local0 > 0\\5\\) ? local0 : global1\n"
    "              )\n"
    "              Reaching definitions: \n"
    "              Live variables: \n");

  std::ostringstream ost;
  rtl->print(ost);
  std::string actual = ost.str();
  CPPUNIT_ASSERT_EQUAL(expected, actual);
}