@@ -634,6 +634,7 @@ class MasmParser : public MCAsmParser {
634
634
DK_DW,
635
635
DK_REAL4,
636
636
DK_REAL8,
637
+ DK_REAL10,
637
638
DK_ALIGN,
638
639
DK_ORG,
639
640
DK_ENDR,
@@ -771,7 +772,7 @@ class MasmParser : public MCAsmParser {
771
772
bool parseDirectiveNamedValue (StringRef TypeName, unsigned Size,
772
773
StringRef Name, SMLoc NameLoc);
773
774
774
- // "real4", "real8"
775
+ // "real4", "real8", "real10"
775
776
bool emitRealValues (const fltSemantics &Semantics, unsigned *Count = nullptr );
776
777
bool addRealField (StringRef Name, const fltSemantics &Semantics, size_t Size);
777
778
bool parseDirectiveRealValue (StringRef IDVal, const fltSemantics &Semantics,
@@ -2147,6 +2148,8 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
2147
2148
return parseDirectiveRealValue (IDVal, APFloat::IEEEsingle (), 4 );
2148
2149
case DK_REAL8:
2149
2150
return parseDirectiveRealValue (IDVal, APFloat::IEEEdouble (), 8 );
2151
+ case DK_REAL10:
2152
+ return parseDirectiveRealValue (IDVal, APFloat::x87DoubleExtended (), 10 );
2150
2153
case DK_STRUCT:
2151
2154
case DK_UNION:
2152
2155
return parseDirectiveNestedStruct (IDVal, DirKind);
@@ -2382,6 +2385,10 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
2382
2385
Lex ();
2383
2386
return parseDirectiveNamedRealValue (nextVal, APFloat::IEEEdouble (), 8 ,
2384
2387
IDVal, IDLoc);
2388
+ case DK_REAL10:
2389
+ Lex ();
2390
+ return parseDirectiveNamedRealValue (nextVal, APFloat::x87DoubleExtended (),
2391
+ 10 , IDVal, IDLoc);
2385
2392
case DK_STRUCT:
2386
2393
case DK_UNION:
2387
2394
Lex ();
@@ -3456,14 +3463,14 @@ bool MasmParser::parseRealValue(const fltSemantics &Semantics, APInt &Res) {
3456
3463
} else if (IDVal.consume_back (" r" ) || IDVal.consume_back (" R" )) {
3457
3464
// MASM hexadecimal floating-point literal; no APFloat conversion needed.
3458
3465
// To match ML64.exe, ignore the initial sign.
3459
- unsigned Size = Value.getSizeInBits (Semantics);
3460
- if (Size != (IDVal.size () << 2 ))
3466
+ unsigned SizeInBits = Value.getSizeInBits (Semantics);
3467
+ if (SizeInBits != (IDVal.size () << 2 ))
3461
3468
return TokError (" invalid floating point literal" );
3462
3469
3463
3470
// Consume the numeric token.
3464
3471
Lex ();
3465
3472
3466
- Res = APInt (Size , IDVal, 16 );
3473
+ Res = APInt (SizeInBits , IDVal, 16 );
3467
3474
if (SignLoc.isValid ())
3468
3475
return Warning (SignLoc, " MASM-style hex floats ignore explicit sign" );
3469
3476
return false ;
@@ -3540,8 +3547,7 @@ bool MasmParser::emitRealValues(const fltSemantics &Semantics,
3540
3547
return true ;
3541
3548
3542
3549
for (const APInt &AsInt : ValuesAsInt) {
3543
- getStreamer ().emitIntValue (AsInt.getLimitedValue (),
3544
- AsInt.getBitWidth () / 8 );
3550
+ getStreamer ().emitIntValue (AsInt);
3545
3551
}
3546
3552
if (Count)
3547
3553
*Count = ValuesAsInt.size ();
@@ -3571,7 +3577,7 @@ bool MasmParser::addRealField(StringRef Name, const fltSemantics &Semantics,
3571
3577
}
3572
3578
3573
3579
// / parseDirectiveRealValue
3574
- // / ::= (real4 | real8) [ expression (, expression)* ]
3580
+ // / ::= (real4 | real8 | real10 ) [ expression (, expression)* ]
3575
3581
bool MasmParser::parseDirectiveRealValue (StringRef IDVal,
3576
3582
const fltSemantics &Semantics,
3577
3583
size_t Size) {
@@ -3586,7 +3592,7 @@ bool MasmParser::parseDirectiveRealValue(StringRef IDVal,
3586
3592
}
3587
3593
3588
3594
// / parseDirectiveNamedRealValue
3589
- // / ::= name (real4 | real8) [ expression (, expression)* ]
3595
+ // / ::= name (real4 | real8 | real10 ) [ expression (, expression)* ]
3590
3596
bool MasmParser::parseDirectiveNamedRealValue (StringRef TypeName,
3591
3597
const fltSemantics &Semantics,
3592
3598
unsigned Size, StringRef Name,
@@ -3680,29 +3686,41 @@ bool MasmParser::parseFieldInitializer(const FieldInfo &Field,
3680
3686
bool MasmParser::parseFieldInitializer (const FieldInfo &Field,
3681
3687
const RealFieldInfo &Contents,
3682
3688
FieldInitializer &Initializer) {
3683
- const fltSemantics &Semantics =
3684
- (Field.Type == 4 ) ? APFloat::IEEEsingle () : APFloat::IEEEdouble ();
3689
+ const fltSemantics *Semantics;
3690
+ switch (Field.Type ) {
3691
+ case 4 :
3692
+ Semantics = &APFloat::IEEEsingle ();
3693
+ break ;
3694
+ case 8 :
3695
+ Semantics = &APFloat::IEEEdouble ();
3696
+ break ;
3697
+ case 10 :
3698
+ Semantics = &APFloat::x87DoubleExtended ();
3699
+ break ;
3700
+ default :
3701
+ llvm_unreachable (" unknown real field type" );
3702
+ }
3685
3703
3686
3704
SMLoc Loc = getTok ().getLoc ();
3687
3705
3688
3706
SmallVector<APInt, 1 > AsIntValues;
3689
3707
if (parseOptionalToken (AsmToken::LCurly)) {
3690
3708
if (Field.LengthOf == 1 )
3691
3709
return Error (Loc, " Cannot initialize scalar field with array value" );
3692
- if (parseRealInstList (Semantics, AsIntValues, AsmToken::RCurly) ||
3710
+ if (parseRealInstList (* Semantics, AsIntValues, AsmToken::RCurly) ||
3693
3711
parseToken (AsmToken::RCurly))
3694
3712
return true ;
3695
3713
} else if (parseOptionalAngleBracketOpen ()) {
3696
3714
if (Field.LengthOf == 1 )
3697
3715
return Error (Loc, " Cannot initialize scalar field with array value" );
3698
- if (parseRealInstList (Semantics, AsIntValues, AsmToken::Greater) ||
3716
+ if (parseRealInstList (* Semantics, AsIntValues, AsmToken::Greater) ||
3699
3717
parseAngleBracketClose ())
3700
3718
return true ;
3701
3719
} else if (Field.LengthOf > 1 ) {
3702
3720
return Error (Loc, " Cannot initialize array field with scalar value" );
3703
3721
} else {
3704
3722
AsIntValues.emplace_back ();
3705
- if (parseRealValue (Semantics, AsIntValues.back ()))
3723
+ if (parseRealValue (* Semantics, AsIntValues.back ()))
3706
3724
return true ;
3707
3725
}
3708
3726
@@ -6278,6 +6296,7 @@ void MasmParser::initializeDirectiveKindMap() {
6278
6296
DirectiveKindMap[" sqword" ] = DK_SQWORD;
6279
6297
DirectiveKindMap[" real4" ] = DK_REAL4;
6280
6298
DirectiveKindMap[" real8" ] = DK_REAL8;
6299
+ DirectiveKindMap[" real10" ] = DK_REAL10;
6281
6300
DirectiveKindMap[" align" ] = DK_ALIGN;
6282
6301
// DirectiveKindMap[".org"] = DK_ORG;
6283
6302
DirectiveKindMap[" extern" ] = DK_EXTERN;
@@ -6732,6 +6751,7 @@ bool MasmParser::lookUpType(StringRef Name, AsmTypeInfo &Info) const {
6732
6751
.CasesLower (" qword" , " dq" , " sqword" , 8 )
6733
6752
.CaseLower (" real4" , 4 )
6734
6753
.CaseLower (" real8" , 8 )
6754
+ .CaseLower (" real10" , 10 )
6735
6755
.Default (0 );
6736
6756
if (Size) {
6737
6757
Info.Name = Name;
0 commit comments