3 // Copyright (c) 2003-2005 The Regents of The University of Michigan
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met: redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer;
10 // redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution;
13 // neither the name of the copyright holders nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // Authors: Steve Reinhardt
31 ////////////////////////////////////////////////////////////////////
33 // Integer operate instructions
38 * Base class for integer immediate instructions.
40 class IntegerImm : public AlphaStaticInst
43 /// Immediate operand value (unsigned 8-bit int).
47 IntegerImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
48 : AlphaStaticInst(mnem, _machInst, __opClass), imm(INTIMM)
53 generateDisassembly(Addr pc, const SymbolTable *symtab) const;
59 IntegerImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const
63 ccprintf(ss, "%-10s ", mnemonic);
65 // just print the first source reg... if there's
66 // a second one, it's a read-modify-write dest (Rc),
68 if (_numSrcRegs > 0) {
69 printReg(ss, _srcRegIdx[0]);
75 if (_numDestRegs > 0) {
77 printReg(ss, _destRegIdx[0]);
85 def template RegOrImmDecode {{
88 (IMM) ? (AlphaStaticInst *)new %(class_name)sImm(machInst)
89 : (AlphaStaticInst *)new %(class_name)s(machInst);
97 // Primary format for integer operate instructions:
98 // - Generates both reg-reg and reg-imm versions if Rb_or_imm is used.
99 // - Generates NOP if RC == 31.
100 def format IntegerOperate(code, *opt_flags) {{
101 # If the code block contains 'Rb_or_imm', we define two instructions,
102 # one using 'Rb' and one using 'imm', and have the decoder select
104 uses_imm = (code.find('Rb_or_imm') != -1)
107 # base code is reg version:
108 # rewrite by substituting 'Rb' for 'Rb_or_imm'
109 code = re.sub(r'Rb_or_imm', 'Rb', orig_code)
110 # generate immediate version by substituting 'imm'
111 # note that imm takes no extenstion, so we extend
112 # the regexp to replace any extension as well
113 imm_code = re.sub(r'Rb_or_imm(\.\w+)?', 'imm', orig_code)
115 # generate declaration for register version
116 iop = InstObjParams(name, Name, 'AlphaStaticInst', code, opt_flags)
117 header_output = BasicDeclare.subst(iop)
118 decoder_output = BasicConstructor.subst(iop)
119 exec_output = BasicExecute.subst(iop)
122 # append declaration for imm version
123 imm_iop = InstObjParams(name, Name + 'Imm', 'IntegerImm', imm_code,
125 header_output += BasicDeclare.subst(imm_iop)
126 decoder_output += BasicConstructor.subst(imm_iop)
127 exec_output += BasicExecute.subst(imm_iop)
128 # decode checks IMM bit to pick correct version
129 decode_block = RegOrImmDecode.subst(iop)
131 # no imm version: just check for nop
132 decode_block = OperateNopCheckDecode.subst(iop)