⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md.texi

📁 理解和实践操作系统的一本好书
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
The program @command{genrecog} scans @code{define_predicate} and@code{define_special_predicate} expressions to determine which RTXcodes are possibly allowed.  You should always make this explicit inthe RTL predicate expression, using @code{MATCH_OPERAND} and@code{MATCH_CODE}.Here is an example of a simple predicate definition, from the IA64machine description:@smallexample@group;; @r{True if @var{op} is a @code{SYMBOL_REF} which refers to the sdata section.}(define_predicate "small_addr_symbolic_operand"  (and (match_code "symbol_ref")       (match_test "SYMBOL_REF_SMALL_ADDR_P (op)")))@end group@end smallexample@noindentAnd here is another, showing the use of the C block.@smallexample@group;; @r{True if @var{op} is a register operand that is (or could be) a GR reg.}(define_predicate "gr_register_operand"  (match_operand 0 "register_operand")@{  unsigned int regno;  if (GET_CODE (op) == SUBREG)    op = SUBREG_REG (op);  regno = REGNO (op);  return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));@})@end group@end smallexamplePredicates written with @code{define_predicate} automatically includea test that @var{mode} is @code{VOIDmode}, or @var{op} has the samemode as @var{mode}, or @var{op} is a @code{CONST_INT} or@code{CONST_DOUBLE}.  They do @emph{not} check specifically forinteger @code{CONST_DOUBLE}, nor do they test that the value of eitherkind of constant fits in the requested mode.  This is becausetarget-specific predicates that take constants usually have to do morestringent value checks anyway.  If you need the exact same treatmentof @code{CONST_INT} or @code{CONST_DOUBLE} that the generic predicatesprovide, use a @code{MATCH_OPERAND} subexpression to call@code{const_int_operand}, @code{const_double_operand}, or@code{immediate_operand}.Predicates written with @code{define_special_predicate} do not get anyautomatic mode checks, and are treated as having special mode handlingby @command{genrecog}.The program @command{genpreds} is responsible for generating code totest predicates.  It also writes a header file containing functiondeclarations for all machine-specific predicates.  It is not necessaryto declare these predicates in @file{@var{cpu}-protos.h}.@end ifset@c Most of this node appears by itself (in a different place) even@c when the INTERNALS flag is clear.  Passages that require the internals@c manual's context are conditionalized to appear only in the internals manual.@ifset INTERNALS@node Constraints@section Operand Constraints@cindex operand constraints@cindex constraintsEach @code{match_operand} in an instruction pattern can specifyconstraints for the operands allowed.  The constraints allow you tofine-tune matching within the set of operands allowed by thepredicate.@end ifset@ifclear INTERNALS@node Constraints@section Constraints for @code{asm} Operands@cindex operand constraints, @code{asm}@cindex constraints, @code{asm}@cindex @code{asm} constraintsHere are specific details on what constraint letters you can use with@code{asm} operands.@end ifclearConstraints can say whetheran operand may be in a register, and which kinds of register; whether theoperand can be a memory reference, and which kinds of address; whether theoperand may be an immediate constant, and which possible values it mayhave.  Constraints can also require two operands to match.@ifset INTERNALS@menu* Simple Constraints::  Basic use of constraints.* Multi-Alternative::   When an insn has two alternative constraint-patterns.* Class Preferences::   Constraints guide which hard register to put things in.* Modifiers::           More precise control over effects of constraints.* Machine Constraints:: Existing constraints for some particular machines.* Define Constraints::  How to define machine-specific constraints.* C Constraint Interface:: How to test constraints from C code.@end menu@end ifset@ifclear INTERNALS@menu* Simple Constraints::  Basic use of constraints.* Multi-Alternative::   When an insn has two alternative constraint-patterns.* Modifiers::           More precise control over effects of constraints.* Machine Constraints:: Special constraints for some particular machines.@end menu@end ifclear@node Simple Constraints@subsection Simple Constraints@cindex simple constraintsThe simplest kind of constraint is a string full of letters, each ofwhich describes one kind of operand that is permitted.  Here arethe letters that are allowed:@table @asis@item whitespaceWhitespace characters are ignored and can be inserted at any positionexcept the first.  This enables each alternative for different operands tobe visually aligned in the machine description even if they have differentnumber of constraints and modifiers.@cindex @samp{m} in constraint@cindex memory references in constraints@item @samp{m}A memory operand is allowed, with any kind of address that the machinesupports in general.@cindex offsettable address@cindex @samp{o} in constraint@item @samp{o}A memory operand is allowed, but only if the address is@dfn{offsettable}.  This means that adding a small integer (actually,the width in bytes of the operand, as determined by its machine mode)may be added to the address and the result is also a valid memoryaddress.@cindex autoincrement/decrement addressingFor example, an address which is constant is offsettable; so is anaddress that is the sum of a register and a constant (as long as aslightly larger constant is also within the range of address-offsetssupported by the machine); but an autoincrement or autodecrementaddress is not offsettable.  More complicated indirect/indexedaddresses may or may not be offsettable depending on the otheraddressing modes that the machine supports.Note that in an output operand which can be matched by anotheroperand, the constraint letter @samp{o} is valid only when accompaniedby both @samp{<} (if the target machine has predecrement addressing)and @samp{>} (if the target machine has preincrement addressing).@cindex @samp{V} in constraint@item @samp{V}A memory operand that is not offsettable.  In other words, anything thatwould fit the @samp{m} constraint but not the @samp{o} constraint.@cindex @samp{<} in constraint@item @samp{<}A memory operand with autodecrement addressing (either predecrement orpostdecrement) is allowed.@cindex @samp{>} in constraint@item @samp{>}A memory operand with autoincrement addressing (either preincrement orpostincrement) is allowed.@cindex @samp{r} in constraint@cindex registers in constraints@item @samp{r}A register operand is allowed provided that it is in a generalregister.@cindex constants in constraints@cindex @samp{i} in constraint@item @samp{i}An immediate integer operand (one with constant value) is allowed.This includes symbolic constants whose values will be known only atassembly time or later.@cindex @samp{n} in constraint@item @samp{n}An immediate integer operand with a known numeric value is allowed.Many systems cannot support assembly-time constants for operands lessthan a word wide.  Constraints for these operands should use @samp{n}rather than @samp{i}.@cindex @samp{I} in constraint@item @samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}Other letters in the range @samp{I} through @samp{P} may be defined ina machine-dependent fashion to permit immediate integer operands withexplicit integer values in specified ranges.  For example, on the68000, @samp{I} is defined to stand for the range of values 1 to 8.This is the range permitted as a shift count in the shiftinstructions.@cindex @samp{E} in constraint@item @samp{E}An immediate floating operand (expression code @code{const_double}) isallowed, but only if the target floating point format is the same asthat of the host machine (on which the compiler is running).@cindex @samp{F} in constraint@item @samp{F}An immediate floating operand (expression code @code{const_double} or@code{const_vector}) is allowed.@cindex @samp{G} in constraint@cindex @samp{H} in constraint@item @samp{G}, @samp{H}@samp{G} and @samp{H} may be defined in a machine-dependent fashion topermit immediate floating operands in particular ranges of values.@cindex @samp{s} in constraint@item @samp{s}An immediate integer operand whose value is not an explicit integer isallowed.This might appear strange; if an insn allows a constant operand with avalue not known at compile time, it certainly must allow any knownvalue.  So why use @samp{s} instead of @samp{i}?  Sometimes it allowsbetter code to be generated.For example, on the 68000 in a fullword instruction it is possible touse an immediate operand; but if the immediate value is between @minus{}128and 127, better code results from loading the value into a register andusing the register.  This is because the load into the register can bedone with a @samp{moveq} instruction.  We arrange for this to happenby defining the letter @samp{K} to mean ``any integer outside therange @minus{}128 to 127'', and then specifying @samp{Ks} in the operandconstraints.@cindex @samp{g} in constraint@item @samp{g}Any register, memory or immediate integer operand is allowed, except forregisters that are not general registers.@cindex @samp{X} in constraint@item @samp{X}@ifset INTERNALSAny operand whatsoever is allowed, even if it does not satisfy@code{general_operand}.  This is normally used in the constraint ofa @code{match_scratch} when certain alternatives will not actuallyrequire a scratch register.@end ifset@ifclear INTERNALSAny operand whatsoever is allowed.@end ifclear@cindex @samp{0} in constraint@cindex digits in constraint@item @samp{0}, @samp{1}, @samp{2}, @dots{} @samp{9}An operand that matches the specified operand number is allowed.  If adigit is used together with letters within the same alternative, thedigit should come last.This number is allowed to be more than a single digit.  If multipledigits are encountered consecutively, they are interpreted as a singledecimal integer.  There is scant chance for ambiguity, since to-dateit has never been desirable that @samp{10} be interpreted as matchingeither operand 1 @emph{or} operand 0.  Should this be desired, onecan use multiple alternatives instead.@cindex matching constraint@cindex constraint, matchingThis is called a @dfn{matching constraint} and what it really means isthat the assembler has only a single operand that fills two roles@ifset INTERNALSconsidered separate in the RTL insn.  For example, an add insn has twoinput operands and one output operand in the RTL, but on most CISC@end ifset@ifclear INTERNALSwhich @code{asm} distinguishes.  For example, an add instruction usestwo input operands and an output operand, but on most CISC@end ifclearmachines an add instruction really has only two operands, one of them aninput-output operand:@smallexampleaddl #35,r12@end smallexampleMatching constraints are used in these circumstances.More precisely, the two operands that match must include one input-onlyoperand and one output-only operand.  Moreover, the digit must be asmaller number than the number of the operand that uses it in theconstraint.@ifset INTERNALSFor operands to match in a particular case usually means that theyare identical-looking RTL expressions.  But in a few special casesspecific kinds of dissimilarity are allowed.  For example, @code{*x}as an input operand will match @code{*x++} as an output operand.For proper results in such cases, the output template should alwaysuse the output-operand's number when printing the operand.@end ifset@cindex load address instruction@cindex push address instruction@cindex address constraints@cindex @samp{p} in constraint@item @samp{p}An operand that is a valid memory address is allowed.  This isfor ``load address'' and ``push address'' instructions.@findex address_operand@samp{p} in the constraint must be accompanied by @code{address_operand}as the predicate in the @code{match_operand}.  This predicate interpretsthe mode specified in the @code{match_operand} as the mode of the memoryreference for which the address would be valid.@cindex other register constraints@cindex extensible constraints

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -