Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: src/IceInstX8632.cpp

Issue 570713006: Subzero: Refactor Operand::dump(). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use a more general dump function Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceOperand.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the InstX8632 and OperandX8632 classes, 10 // This file implements the InstX8632 and OperandX8632 classes,
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 Str << "\n"; 1349 Str << "\n";
1350 } 1350 }
1351 1351
1352 void InstX8632Xchg::dump(const Cfg *Func) const { 1352 void InstX8632Xchg::dump(const Cfg *Func) const {
1353 Ostream &Str = Func->getContext()->getStrDump(); 1353 Ostream &Str = Func->getContext()->getStrDump();
1354 Type Ty = getSrc(0)->getType(); 1354 Type Ty = getSrc(0)->getType();
1355 Str << "xchg." << Ty << " "; 1355 Str << "xchg." << Ty << " ";
1356 dumpSources(Func); 1356 dumpSources(Func);
1357 } 1357 }
1358 1358
1359 void OperandX8632::dump(const Cfg *Func) const {
1360 Ostream &Str = Func->getContext()->getStrDump();
1361 Str << "<OperandX8632>";
1362 }
1363
1364 void OperandX8632Mem::emit(const Cfg *Func) const { 1359 void OperandX8632Mem::emit(const Cfg *Func) const {
1365 Ostream &Str = Func->getContext()->getStrEmit(); 1360 Ostream &Str = Func->getContext()->getStrEmit();
1366 Str << TypeX8632Attributes[getType()].WidthString << " "; 1361 Str << TypeX8632Attributes[getType()].WidthString << " ";
1367 if (SegmentReg != DefaultSegment) { 1362 if (SegmentReg != DefaultSegment) {
1368 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 1363 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
1369 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; 1364 Str << InstX8632SegmentRegNames[SegmentReg] << ":";
1370 } 1365 }
1371 // TODO: The following is an almost verbatim paste of dump(). 1366 // TODO: The following is an almost verbatim paste of dump().
1372 bool Dumped = false; 1367 bool Dumped = false;
1373 Str << "["; 1368 Str << "[";
(...skipping 24 matching lines...) Expand all
1398 Str << "+"; 1393 Str << "+";
1399 Offset->emit(Func); 1394 Offset->emit(Func);
1400 } 1395 }
1401 } else { 1396 } else {
1402 // There is only the offset. 1397 // There is only the offset.
1403 Offset->emit(Func); 1398 Offset->emit(Func);
1404 } 1399 }
1405 Str << "]"; 1400 Str << "]";
1406 } 1401 }
1407 1402
1408 void OperandX8632Mem::dump(const Cfg *Func) const { 1403 void OperandX8632Mem::dump(const Cfg *Func, Ostream &Str) const {
1409 Ostream &Str = Func->getContext()->getStrDump();
1410 if (SegmentReg != DefaultSegment) { 1404 if (SegmentReg != DefaultSegment) {
1411 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 1405 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
1412 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; 1406 Str << InstX8632SegmentRegNames[SegmentReg] << ":";
1413 } 1407 }
1414 bool Dumped = false; 1408 bool Dumped = false;
1415 Str << "["; 1409 Str << "[";
1416 if (Base) { 1410 if (Base) {
1417 Base->dump(Func); 1411 if (Func)
1412 Base->dump(Func);
1413 else
1414 Base->dump(Str);
1418 Dumped = true; 1415 Dumped = true;
1419 } 1416 }
1420 if (Index) { 1417 if (Index) {
1421 assert(Base); 1418 assert(Base);
1422 Str << "+"; 1419 Str << "+";
1423 if (Shift > 0) 1420 if (Shift > 0)
1424 Str << (1u << Shift) << "*"; 1421 Str << (1u << Shift) << "*";
1425 Index->dump(Func); 1422 if (Func)
1423 Index->dump(Func);
1424 else
1425 Index->dump(Str);
1426 Dumped = true; 1426 Dumped = true;
1427 } 1427 }
1428 // Pretty-print the Offset. 1428 // Pretty-print the Offset.
1429 bool OffsetIsZero = false; 1429 bool OffsetIsZero = false;
1430 bool OffsetIsNegative = false; 1430 bool OffsetIsNegative = false;
1431 if (Offset == NULL) { 1431 if (Offset == NULL) {
1432 OffsetIsZero = true; 1432 OffsetIsZero = true;
1433 } else if (ConstantInteger *CI = llvm::dyn_cast<ConstantInteger>(Offset)) { 1433 } else if (ConstantInteger *CI = llvm::dyn_cast<ConstantInteger>(Offset)) {
1434 OffsetIsZero = (CI->getValue() == 0); 1434 OffsetIsZero = (CI->getValue() == 0);
1435 OffsetIsNegative = (static_cast<int64_t>(CI->getValue()) < 0); 1435 OffsetIsNegative = (static_cast<int64_t>(CI->getValue()) < 0);
1436 } 1436 }
1437 if (Dumped) { 1437 if (Dumped) {
1438 if (!OffsetIsZero) { // Suppress if Offset is known to be 0 1438 if (!OffsetIsZero) { // Suppress if Offset is known to be 0
1439 if (!OffsetIsNegative) // Suppress if Offset is known to be negative 1439 if (!OffsetIsNegative) // Suppress if Offset is known to be negative
1440 Str << "+"; 1440 Str << "+";
1441 Offset->dump(Func); 1441 Offset->dump(Func, Str);
1442 } 1442 }
1443 } else { 1443 } else {
1444 // There is only the offset. 1444 // There is only the offset.
1445 Offset->dump(Func); 1445 Offset->dump(Func, Str);
1446 } 1446 }
1447 Str << "]"; 1447 Str << "]";
1448 } 1448 }
1449 1449
1450 void VariableSplit::emit(const Cfg *Func) const { 1450 void VariableSplit::emit(const Cfg *Func) const {
1451 Ostream &Str = Func->getContext()->getStrEmit(); 1451 Ostream &Str = Func->getContext()->getStrEmit();
1452 assert(Var->getLocalUseNode() == NULL || 1452 assert(Var->getLocalUseNode() == NULL ||
1453 Var->getLocalUseNode() == Func->getCurrentNode()); 1453 Var->getLocalUseNode() == Func->getCurrentNode());
1454 assert(!Var->hasReg()); 1454 assert(!Var->hasReg());
1455 // The following is copied/adapted from TargetX8632::emitVariable(). 1455 // The following is copied/adapted from TargetX8632::emitVariable().
1456 const TargetLowering *Target = Func->getTarget(); 1456 const TargetLowering *Target = Func->getTarget();
1457 const Type Ty = IceType_i32; 1457 const Type Ty = IceType_i32;
1458 Str << TypeX8632Attributes[Ty].WidthString << " [" 1458 Str << TypeX8632Attributes[Ty].WidthString << " ["
1459 << Target->getRegName(Target->getFrameOrStackReg(), Ty); 1459 << Target->getRegName(Target->getFrameOrStackReg(), Ty);
1460 int32_t Offset = Var->getStackOffset() + Target->getStackAdjustment(); 1460 int32_t Offset = Var->getStackOffset() + Target->getStackAdjustment();
1461 if (Part == High) 1461 if (Part == High)
1462 Offset += 4; 1462 Offset += 4;
1463 if (Offset) { 1463 if (Offset) {
1464 if (Offset > 0) 1464 if (Offset > 0)
1465 Str << "+"; 1465 Str << "+";
1466 Str << Offset; 1466 Str << Offset;
1467 } 1467 }
1468 Str << "]"; 1468 Str << "]";
1469 } 1469 }
1470 1470
1471 void VariableSplit::dump(const Cfg *Func) const { 1471 void VariableSplit::dump(const Cfg *Func, Ostream &Str) const {
1472 Ostream &Str = Func->getContext()->getStrDump();
1473 switch (Part) { 1472 switch (Part) {
1474 case Low: 1473 case Low:
1475 Str << "low"; 1474 Str << "low";
1476 break; 1475 break;
1477 case High: 1476 case High:
1478 Str << "high"; 1477 Str << "high";
1479 break; 1478 break;
1480 default: 1479 default:
1481 Str << "???"; 1480 Str << "???";
1482 break; 1481 break;
1483 } 1482 }
1484 Str << "("; 1483 Str << "(";
1485 Var->dump(Func); 1484 if (Func)
1485 Var->dump(Func);
1486 else
1487 Var->dump(Str);
1486 Str << ")"; 1488 Str << ")";
1487 } 1489 }
1488 1490
1489 } // end of namespace Ice 1491 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceOperand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698