-//===----------------------------------------------------------------------===//
-// Instruction Analysis
-//===----------------------------------------------------------------------===//
-
-class InstAnalyzer {
- const CodeGenDAGPatterns &CDP;
- bool &mayStore;
- bool &isLoad;
- bool &NeverHasSideEffects;
-public:
- InstAnalyzer(const CodeGenDAGPatterns &cdp,
- bool &maystore, bool &isload, bool &nhse)
- : CDP(cdp), mayStore(maystore), isLoad(isload), NeverHasSideEffects(nhse) {
- }
-
- void Analyze(Record *InstRecord) {
- const TreePattern *Pattern = CDP.getInstruction(InstRecord).getPattern();
- if (Pattern == 0) return; // No pattern.
-
- // Assume there is no side-effect unless we see one.
- NeverHasSideEffects = true;
-
- // FIXME: Assume only the first tree is the pattern. The others are clobber
- // nodes.
- AnalyzeNode(Pattern->getTree(0));
- }
-
-private:
- void AnalyzeNode(const TreePatternNode *N) {
- if (N->isLeaf()) {
- return;
- }
-
- if (N->getOperator()->getName() != "set") {
- // Get information about the SDNode for the operator.
- const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
-
- // If node writes to memory, it obviously stores to memory.
- if (OpInfo.hasProperty(SDNPMayStore)) {
- mayStore = true;
- } else if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
- // If this is an intrinsic, analyze it.
- if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem)
- mayStore = true;// Intrinsics that can write to memory are 'mayStore'.
+void InstrInfoEmitter::DetectRegisterClassBarriers(std::vector<Record*> &Defs,
+ const std::vector<CodeGenRegisterClass> &RCs,
+ std::vector<Record*> &Barriers) {
+ std::set<Record*> DefSet;
+ unsigned NumDefs = Defs.size();
+ for (unsigned i = 0; i < NumDefs; ++i)
+ DefSet.insert(Defs[i]);
+
+ for (unsigned i = 0, e = RCs.size(); i != e; ++i) {
+ const CodeGenRegisterClass &RC = RCs[i];
+ unsigned NumRegs = RC.Elements.size();
+ if (NumRegs > NumDefs)
+ continue; // Can't possibly clobber this RC.
+
+ bool Clobber = true;
+ for (unsigned j = 0; j < NumRegs; ++j) {
+ Record *Reg = RC.Elements[j];
+ if (!DefSet.count(Reg)) {
+ Clobber = false;
+ break;