@@ -1849,75 +1849,8 @@ NVPTXAsmPrinter::lowerConstantForGV(const Constant *CV,
1849
1849
report_fatal_error (Twine (OS.str ()));
1850
1850
}
1851
1851
1852
- // Copy of MCExpr::print customized for NVPTX
1853
1852
void NVPTXAsmPrinter::printMCExpr (const MCExpr &Expr, raw_ostream &OS) const {
1854
- switch (Expr.getKind ()) {
1855
- case MCExpr::Target:
1856
- return cast<MCTargetExpr>(&Expr)->printImpl (OS, MAI);
1857
- case MCExpr::Constant:
1858
- OS << cast<MCConstantExpr>(Expr).getValue ();
1859
- return ;
1860
-
1861
- case MCExpr::SymbolRef: {
1862
- const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(Expr);
1863
- const MCSymbol &Sym = SRE.getSymbol ();
1864
- Sym.print (OS, MAI);
1865
- return ;
1866
- }
1867
-
1868
- case MCExpr::Unary: {
1869
- const MCUnaryExpr &UE = cast<MCUnaryExpr>(Expr);
1870
- switch (UE.getOpcode ()) {
1871
- case MCUnaryExpr::LNot: OS << ' !' ; break ;
1872
- case MCUnaryExpr::Minus: OS << ' -' ; break ;
1873
- case MCUnaryExpr::Not: OS << ' ~' ; break ;
1874
- case MCUnaryExpr::Plus: OS << ' +' ; break ;
1875
- }
1876
- printMCExpr (*UE.getSubExpr (), OS);
1877
- return ;
1878
- }
1879
-
1880
- case MCExpr::Binary: {
1881
- const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1882
-
1883
- // Only print parens around the LHS if it is non-trivial.
1884
- if (isa<MCConstantExpr>(BE.getLHS ()) || isa<MCSymbolRefExpr>(BE.getLHS ()) ||
1885
- isa<NVPTXGenericMCSymbolRefExpr>(BE.getLHS ())) {
1886
- printMCExpr (*BE.getLHS (), OS);
1887
- } else {
1888
- OS << ' (' ;
1889
- printMCExpr (*BE.getLHS (), OS);
1890
- OS<< ' )' ;
1891
- }
1892
-
1893
- switch (BE.getOpcode ()) {
1894
- case MCBinaryExpr::Add:
1895
- // Print "X-42" instead of "X+-42".
1896
- if (const MCConstantExpr *RHSC = dyn_cast<MCConstantExpr>(BE.getRHS ())) {
1897
- if (RHSC->getValue () < 0 ) {
1898
- OS << RHSC->getValue ();
1899
- return ;
1900
- }
1901
- }
1902
-
1903
- OS << ' +' ;
1904
- break ;
1905
- default : llvm_unreachable (" Unhandled binary operator" );
1906
- }
1907
-
1908
- // Only print parens around the LHS if it is non-trivial.
1909
- if (isa<MCConstantExpr>(BE.getRHS ()) || isa<MCSymbolRefExpr>(BE.getRHS ())) {
1910
- printMCExpr (*BE.getRHS (), OS);
1911
- } else {
1912
- OS << ' (' ;
1913
- printMCExpr (*BE.getRHS (), OS);
1914
- OS << ' )' ;
1915
- }
1916
- return ;
1917
- }
1918
- }
1919
-
1920
- llvm_unreachable (" Invalid expression kind!" );
1853
+ Expr.print (OS, OutContext.getAsmInfo ());
1921
1854
}
1922
1855
1923
1856
// / PrintAsmOperand - Print out an operand for an inline asm expression.
0 commit comments