AirLowerMacros.cpp [plain text]
#include "config.h"
#include "AirLowerMacros.h"
#if ENABLE(B3_JIT)
#include "AirCCallingConvention.h"
#include "AirCode.h"
#include "AirInsertionSet.h"
#include "AirInstInlines.h"
#include "AirPhaseScope.h"
#include "B3CCallValue.h"
#include "B3ValueInlines.h"
namespace JSC { namespace B3 { namespace Air {
void lowerMacros(Code& code)
{
PhaseScope phaseScope(code, "lowerMacros");
InsertionSet insertionSet(code);
for (BasicBlock* block : code) {
for (unsigned instIndex = 0; instIndex < block->size(); ++instIndex) {
Inst& inst = block->at(instIndex);
switch (inst.opcode) {
case CCall: {
CCallValue* value = inst.origin->as<CCallValue>();
Vector<Arg> destinations = computeCCallingConvention(code, value);
Inst shuffleArguments(Shuffle, value);
unsigned offset = value->type() == Void ? 0 : 1;
for (unsigned i = 1; i < destinations.size(); ++i) {
Value* child = value->child(i);
shuffleArguments.args.append(inst.args[offset + i]);
shuffleArguments.args.append(destinations[i]);
shuffleArguments.args.append(Arg::widthArg(Arg::widthForB3Type(child->type())));
}
insertionSet.insertInst(instIndex, WTFMove(shuffleArguments));
destinations[0] = inst.args[0];
Arg resultDst = value->type() == Void ? Arg() : inst.args[1];
inst = buildCCall(code, inst.origin, destinations);
Tmp result = cCallResult(value->type());
switch (value->type()) {
case Void:
break;
case Float:
insertionSet.insert(instIndex + 1, MoveFloat, value, result, resultDst);
break;
case Double:
insertionSet.insert(instIndex + 1, MoveDouble, value, result, resultDst);
break;
case Int32:
insertionSet.insert(instIndex + 1, Move32, value, result, resultDst);
break;
case Int64:
insertionSet.insert(instIndex + 1, Move, value, result, resultDst);
break;
}
break;
}
default:
break;
}
}
insertionSet.execute(block);
}
}
} } }
#endif // ENABLE(B3_JIT)