protected virtual bool CallGenCreateMemory64 => false; // The methods are deprecated protected virtual void GenCreateMemory64(FileWriter writer, CreateMethod method) { if (CallGenCreateMemory64) { throw new InvalidOperationException(); } }
static CreateMethod GetMethod(InstructionGroup group, bool unsigned) { var(regCount, immCount, memCount) = GetOpKindCount(group); int regId = 1, immId = 1, memId = 1; string doc = group.Operands.Length switch { 0 => "Creates an instruction with no operands", 1 => "Creates an instruction with 1 operand", _ => $"Creates an instruction with {group.Operands.Length} operands", }; var method = new CreateMethod(doc); AddCodeArg(method); int opNum = -1; foreach (var op in group.Operands) { opNum++; switch (op) { case InstructionOperand.Register: method.Args.Add(new MethodArg($"op{opNum}: Register", MethodArgType.Register, GetArgName("register", regCount, regId++))); break; case InstructionOperand.Memory: method.Args.Add(new MethodArg($"op{opNum}: Memory operand", MethodArgType.Memory, GetArgName("memory", memCount, memId++))); break; case InstructionOperand.Imm32: method.Args.Add(new MethodArg($"op{opNum}: Immediate value", unsigned ? MethodArgType.UInt32 : MethodArgType.Int32, GetArgName("immediate", immCount, immId++))); break; case InstructionOperand.Imm64: method.Args.Add(new MethodArg($"op{opNum}: Immediate value", unsigned ? MethodArgType.UInt64 : MethodArgType.Int64, GetArgName("immediate", immCount, immId++))); break; default: throw new InvalidOperationException(); } } return(method);
protected abstract void GenCreateFarBranch(FileWriter writer, CreateMethod method);
protected abstract void GenCreate(FileWriter writer, CreateMethod method, InstructionGroup group);
void AddRepPrefixArg(CreateMethod method) => method.Args.Add(new MethodArg("Rep prefix or #(e:RepPrefixKind.None)#", MethodArgType.RepPrefixKind, "repPrefix", genTypes[TypeIds.RepPrefixKind][nameof(RepPrefixKind.None)]));
void AddSegmentPrefixArg(CreateMethod method) => method.Args.Add(new MethodArg("Segment override or #(e:Register.None)#", MethodArgType.Register, "segmentPrefix", genTypes[TypeIds.Register][nameof(Register.None)]));
static void AddRepPrefixArg(CreateMethod method) => method.Args.Add(new MethodArg("Rep prefix or #(e:RepPrefixKind.None)#", MethodArgType.RepPrefixKind, "repPrefix", RepPrefixKindEnum.Instance[nameof(RepPrefixKind.None)]));
protected abstract void GenCreateString_ESRDI_Reg(FileWriter writer, CreateMethod method, StringMethodKind kind, string methodBaseName, EnumValue code, EnumValue register);
static void AddAddressSizeArg(CreateMethod method) => method.Args.Add(new MethodArg("16, 32, or 64", MethodArgType.PreferedInt32, "addressSize"));
static void AddCodeArg(CreateMethod method) => method.Args.Add(new MethodArg("Code value", MethodArgType.Code, "code"));
protected abstract void GenCreateDeclareDataArrayLength(FileWriter writer, CreateMethod method, DeclareDataKind kind, ArrayType arrayType);
protected abstract void GenCreateDeclareData(FileWriter writer, CreateMethod method, DeclareDataKind kind);
protected abstract void GenCreateMaskmov(FileWriter writer, CreateMethod method, string methodBaseName, EnumValue code);
protected abstract void GenCreateXbegin(FileWriter writer, CreateMethod method);
static void AddTargetArg(CreateMethod method) => method.Args.Add(new MethodArg("Target address", MethodArgType.UInt64, "target"));
protected abstract void GenCreateMemory64(FileWriter writer, CreateMethod method);
static void AddBitnessArg(CreateMethod method) => method.Args.Add(new MethodArg("16, 32, or 64", MethodArgType.PreferedInt32, "bitness"));
protected abstract void GenCreateString_SegRSI_ESRDI(FileWriter writer, CreateMethod method, StringMethodKind kind, string methodBaseName, EnumValue code);
static void AddSegmentPrefixArg(CreateMethod method) => method.Args.Add(new MethodArg("Segment override or #(e:Register.None)#", MethodArgType.Register, "segmentPrefix", RegisterEnum.Instance[nameof(Register.None)]));