[JitIL] No more terrible usage of vectors.

This is possible because of C++11.
This commit is contained in:
Matthew Parlane 2013-11-06 22:18:08 +13:00
parent 274f6dd7ab
commit 897bec1add
2 changed files with 10 additions and 10 deletions

View File

@ -131,14 +131,14 @@ using namespace Gen;
namespace IREmitter { namespace IREmitter {
InstLoc IRBuilder::EmitZeroOp(unsigned Opcode, unsigned extra = 0) { InstLoc IRBuilder::EmitZeroOp(unsigned Opcode, unsigned extra = 0) {
InstLoc curIndex = &InstList[InstList.size()]; InstLoc curIndex = InstList.data() + InstList.size();
InstList.push_back(Opcode | (extra << 8)); InstList.push_back(Opcode | (extra << 8));
MarkUsed.push_back(false); MarkUsed.push_back(false);
return curIndex; return curIndex;
} }
InstLoc IRBuilder::EmitUOp(unsigned Opcode, InstLoc Op1, unsigned extra) { InstLoc IRBuilder::EmitUOp(unsigned Opcode, InstLoc Op1, unsigned extra) {
InstLoc curIndex = &InstList[InstList.size()]; InstLoc curIndex = InstList.data() + InstList.size();
unsigned backOp1 = (s32)(curIndex - 1 - Op1); unsigned backOp1 = (s32)(curIndex - 1 - Op1);
if (backOp1 >= 256) { if (backOp1 >= 256) {
InstList.push_back(Tramp | backOp1 << 8); InstList.push_back(Tramp | backOp1 << 8);
@ -152,7 +152,7 @@ InstLoc IRBuilder::EmitUOp(unsigned Opcode, InstLoc Op1, unsigned extra) {
} }
InstLoc IRBuilder::EmitBiOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, unsigned extra) { InstLoc IRBuilder::EmitBiOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, unsigned extra) {
InstLoc curIndex = &InstList[InstList.size()]; InstLoc curIndex = InstList.data() + InstList.size();
unsigned backOp1 = (s32)(curIndex - 1 - Op1); unsigned backOp1 = (s32)(curIndex - 1 - Op1);
if (backOp1 >= 255) { if (backOp1 >= 255) {
InstList.push_back(Tramp | backOp1 << 8); InstList.push_back(Tramp | backOp1 << 8);
@ -175,7 +175,7 @@ InstLoc IRBuilder::EmitBiOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, unsigned
#if 0 #if 0
InstLoc IRBuilder::EmitTriOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, InstLoc Op3) { InstLoc IRBuilder::EmitTriOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, InstLoc Op3) {
InstLoc curIndex = &InstList[InstList.size()]; InstLoc curIndex = InstList.data() + InstList.size();
unsigned backOp1 = curIndex - 1 - Op1; unsigned backOp1 = curIndex - 1 - Op1;
if (backOp1 >= 254) { if (backOp1 >= 254) {
InstList.push_back(Tramp | backOp1 << 8); InstList.push_back(Tramp | backOp1 << 8);
@ -1049,7 +1049,7 @@ InstLoc IRBuilder::FoldBiOp(unsigned Opcode, InstLoc Op1, InstLoc Op2, unsigned
} }
InstLoc IRBuilder::EmitIntConst(unsigned value) { InstLoc IRBuilder::EmitIntConst(unsigned value) {
InstLoc curIndex = &InstList[InstList.size()]; InstLoc curIndex = InstList.data() + InstList.size();
InstList.push_back(CInt32 | ((unsigned int)ConstList.size() << 8)); InstList.push_back(CInt32 | ((unsigned int)ConstList.size() << 8));
MarkUsed.push_back(false); MarkUsed.push_back(false);
ConstList.push_back(value); ConstList.push_back(value);
@ -1061,12 +1061,12 @@ unsigned IRBuilder::GetImmValue(InstLoc I) const {
} }
void IRBuilder::SetMarkUsed(InstLoc I) { void IRBuilder::SetMarkUsed(InstLoc I) {
const unsigned i = (unsigned)(I - &InstList[0]); const unsigned i = (unsigned)(I - InstList.data());
MarkUsed[i] = true; MarkUsed[i] = true;
} }
bool IRBuilder::IsMarkUsed(InstLoc I) const { bool IRBuilder::IsMarkUsed(InstLoc I) const {
const unsigned i = (unsigned)(I - &InstList[0]); const unsigned i = (unsigned)(I - InstList.data());
return MarkUsed[i]; return MarkUsed[i];
} }

View File

@ -529,11 +529,11 @@ public:
return FoldZeroOp(Int3, 0); return FoldZeroOp(Int3, 0);
} }
void StartBackPass() { curReadPtr = &InstList[InstList.size()]; } void StartBackPass() { curReadPtr = InstList.data() + InstList.size(); }
void StartForwardPass() { curReadPtr = &InstList[0]; } void StartForwardPass() { curReadPtr = InstList.data(); }
InstLoc ReadForward() { return curReadPtr++; } InstLoc ReadForward() { return curReadPtr++; }
InstLoc ReadBackward() { return --curReadPtr; } InstLoc ReadBackward() { return --curReadPtr; }
InstLoc getFirstInst() { return &InstList[0]; } InstLoc getFirstInst() { return InstList.data(); }
unsigned int getNumInsts() { return (unsigned int)InstList.size(); } unsigned int getNumInsts() { return (unsigned int)InstList.size(); }
unsigned int ReadInst(InstLoc I) { return *I; } unsigned int ReadInst(InstLoc I) { return *I; }
unsigned int GetImmValue(InstLoc I) const; unsigned int GetImmValue(InstLoc I) const;