llvm.org GIT mirror llvm / 248f496
[ms-inline asm] Add the OpDecl to the InlineAsmIdentifierInfo struct and in turn the MCParsedAsmOperand. Part of rdar://13663589 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180054 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 7 years ago
3 changed file(s) with 21 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
3333 class MCAsmParserSemaCallback {
3434 public:
3535 typedef struct {
36 void *OpDecl;
3637 bool IsVarDecl;
3738 unsigned Length, Size, Type;
3839
3940 void clear() {
41 OpDecl = 0;
4042 IsVarDecl = false;
4143 Length = 1;
4244 Size = 0;
3737 unsigned getMCOperandNum() { return MCOperandNum; }
3838
3939 virtual StringRef getSymName() { return StringRef(); }
40 virtual void *getOpDecl() { return 0; }
4041
4142 /// isToken - Is this a token operand?
4243 virtual bool isToken() const = 0;
613613 SMLoc StartLoc, EndLoc;
614614 SMLoc OffsetOfLoc;
615615 StringRef SymName;
616 void *OpDecl;
616617 bool AddressOf;
617618
618619 struct TokOp {
648649 : Kind(K), StartLoc(Start), EndLoc(End) {}
649650
650651 StringRef getSymName() { return SymName; }
652 void *getOpDecl() { return OpDecl; }
651653
652654 /// getStartLoc - Get the location of the first token of this operand.
653655 SMLoc getStartLoc() const { return StartLoc; }
913915 static X86Operand *CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc,
914916 bool AddressOf = false,
915917 SMLoc OffsetOfLoc = SMLoc(),
916 StringRef SymName = StringRef()) {
918 StringRef SymName = StringRef(),
919 void *OpDecl = 0) {
917920 X86Operand *Res = new X86Operand(Register, StartLoc, EndLoc);
918921 Res->Reg.RegNo = RegNo;
919922 Res->AddressOf = AddressOf;
920923 Res->OffsetOfLoc = OffsetOfLoc;
921924 Res->SymName = SymName;
925 Res->OpDecl = OpDecl;
922926 return Res;
923927 }
924928
930934
931935 /// Create an absolute memory operand.
932936 static X86Operand *CreateMem(const MCExpr *Disp, SMLoc StartLoc, SMLoc EndLoc,
933 unsigned Size = 0,
934 StringRef SymName = StringRef()) {
937 unsigned Size = 0, StringRef SymName = StringRef(),
938 void *OpDecl = 0) {
935939 X86Operand *Res = new X86Operand(Memory, StartLoc, EndLoc);
936940 Res->Mem.SegReg = 0;
937941 Res->Mem.Disp = Disp;
939943 Res->Mem.IndexReg = 0;
940944 Res->Mem.Scale = 1;
941945 Res->Mem.Size = Size;
942 Res->SymName = SymName;
943 Res->AddressOf = false;
946 Res->SymName = SymName;
947 Res->OpDecl = OpDecl;
948 Res->AddressOf = false;
944949 return Res;
945950 }
946951
949954 unsigned BaseReg, unsigned IndexReg,
950955 unsigned Scale, SMLoc StartLoc, SMLoc EndLoc,
951956 unsigned Size = 0,
952 StringRef SymName = StringRef()) {
957 StringRef SymName = StringRef(),
958 void *OpDecl = 0) {
953959 // We should never just have a displacement, that should be parsed as an
954960 // absolute memory operand.
955961 assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!");
964970 Res->Mem.IndexReg = IndexReg;
965971 Res->Mem.Scale = Scale;
966972 Res->Mem.Size = Size;
967 Res->SymName = SymName;
968 Res->AddressOf = false;
973 Res->SymName = SymName;
974 Res->OpDecl = OpDecl;
975 Res->AddressOf = false;
969976 return Res;
970977 }
971978 };
11271134 unsigned Scale, SMLoc Start, SMLoc End,
11281135 unsigned Size, StringRef Identifier,
11291136 InlineAsmIdentifierInfo &Info){
1130
1131
11321137 if (Disp && isa(Disp)) {
11331138 // If this is not a VarDecl then assume it is a FuncDecl or some other label
11341139 // reference. We need an 'r' constraint here, so we need to create register
11371142 if (!Info.IsVarDecl) {
11381143 unsigned RegNo = is64BitMode() ? X86::RBX : X86::EBX;
11391144 return X86Operand::CreateReg(RegNo, Start, End, /*AddressOf=*/true,
1140 SMLoc(), Identifier);
1145 SMLoc(), Identifier, Info.OpDecl);
11411146 }
11421147 if (!Size) {
11431148 Size = Info.Type * 8; // Size is in terms of bits in this context.
11521157 // get the matching correct in some cases.
11531158 BaseReg = BaseReg ? BaseReg : 1;
11541159 return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale, Start,
1155 End, Size, Identifier);
1160 End, Size, Identifier, Info.OpDecl);
11561161 }
11571162
11581163 static void
15111516 // the size of a pointer.
15121517 unsigned RegNo = is64BitMode() ? X86::RBX : X86::EBX;
15131518 return X86Operand::CreateReg(RegNo, Start, End, /*GetAddress=*/true,
1514 OffsetOfLoc, Identifier);
1519 OffsetOfLoc, Identifier, Info.OpDecl);
15151520 }
15161521
15171522 enum IntelOperatorKind {