Changeset 3820


Ignore:
Timestamp:
Apr 13, 2014, 10:25:40 PM (4 years ago)
Author:
ksherdy
Message:

Harmonized names.

Location:
proto/s2k/trunk/framework/src/toolchain/b2k/lang
Files:
8 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/B2KBuiltin.java

    r3809 r3820  
    1   package toolchain.b2k.lang;
     1/*
     2 * Builtin Interface.
     3 *
     4 * @author Ken Herdy <ksherdy at sfu dot ca>
     5 *
     6 */
    27
    3   import java.util.ArrayList;
    4   import java.util.List;
    5   import toolchain.b2k.lang.B2KBuiltin;
     8package toolchain.b2k.lang;
    69
    7   public enum B2KBuiltin {
     10public interface B2KBuiltin {
     11                       
     12        /** Yields a printable string for information about this builtin.
     13         * Use this rather than toString() if you want an abbreviated string.
     14         *
     15         * @return string representation of builtin.
     16         */
     17        public String infoString();
     18               
     19        /** Returns the builtin with any builtin variables filled in with their values.
     20         */
     21        public B2KBuiltin getConcreteBuiltin();
     22       
     23}
    824
    9       PRINT_BITBLOCK("PrintBitBlock", CarryType.None, 1),
    10       ASSERT_BITBLOCK_ALIGN("AssertBitBlockAlign", CarryType.None, 1),
    11       EOF_MASK("EOF_mask", CarryType.None, 0), // keywords
    12       DO_BLOCK("do_block", CarryType.None, 0),
    13       DO_FINAL_BLOCK("do_final_block", CarryType.None, 0),
    14       CLEAR("clear", CarryType.None, 0);
    15      
    16       public enum CarryType{One, N, None};   
    17      
    18       private final String name;
    19       private final CarryType type;
    20       private final int argCount;
    21      
    22       private B2KBuiltin(String name, CarryType type, int argCount) {
    23           this.type = type;
    24           this.name = name;
    25           this.argCount = argCount;
    26       }
    27      
    28       public String b2kName() { return this.name; }
    29       public int argCount() { return this.argCount; }
    30       public final CarryType getCarryType() { return type; }
    31      
    32       public static List<B2KBuiltin> carryOneOperations () {
    33          
    34           ArrayList<B2KBuiltin> carryOne = new ArrayList<B2KBuiltin>();
    35          
    36           for (B2KBuiltin operation : B2KBuiltin.values()) {
    37               if (CarryType.One == operation.type) {
    38                   carryOne.add(operation);
    39               }
    40           }
    41          
    42           return carryOne;
    43       }   
    44      
    45       public static List<B2KBuiltin> carryNOperations () {
    46          
    47           ArrayList<B2KBuiltin> carryN = new ArrayList<B2KBuiltin>();
    48          
    49           for (B2KBuiltin operation : B2KBuiltin.values()) {
    50               if (CarryType.N == operation.type) {
    51                   carryN.add(operation);
    52               }
    53           }
    54          
    55           return carryN;
    56       }
    57      
    58   }
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/B2KBuiltins2C.java

    r3788 r3820  
    11package toolchain.b2k.lang;
    22
     3/*
     4 * KH: Refactor to translate s2k2b2k and then b2k2CLang or b2k2CPPLang.
     5 */
     6
     7import java.util.ArrayList;
     8import java.util.Arrays;
    39import java.util.HashMap;
     10import java.util.List;
    411import java.util.Map;
    512
    6 public class B2KBuiltins2C extends AbstractBuiltinEncoder {
     13public class B2KBuiltins2C extends AbstractB2KBuiltinsEncoder {
    714       
    815        private static Map<B2KBuiltin, String> b2k2CCode;
     
    1219        b2k2CCode = new HashMap<B2KBuiltin, String>();
    1320       
    14         b2k2CCode.put(B2KBuiltin.PRINT_BITBLOCK, "print_register<BitBlock>");
    15         b2k2CCode.put(B2KBuiltin.ASSERT_BITBLOCK_ALIGN, "assert_bitblock_align");       
    16         b2k2CCode.put(B2KBuiltin.EOF_MASK, "EOF_mask");
    17         b2k2CCode.put(B2KBuiltin.DO_BLOCK, "do_block");
    18         b2k2CCode.put(B2KBuiltin.DO_FINAL_BLOCK, "do_final_block");
    19         b2k2CCode.put(B2KBuiltin.CLEAR, "clear");
     21        b2k2CCode.put(B2KBuiltins.FLOW_ADVANCE,                         "pablo_blk_Advance");
     22        b2k2CCode.put(B2KBuiltins.FLOW_SCAN_TO_FIRST,                   "pablo_blk_ScanToFirst");
     23        b2k2CCode.put(B2KBuiltins.FLOW_SCAN_THRU,                       "pablo_blk_ScanThru");
     24        b2k2CCode.put(B2KBuiltins.FLOW_SCAN_TO,                         "pablo_blk_ScanTo");
     25        b2k2CCode.put(B2KBuiltins.FLOW_ADVANCE_THEN_SCAN_THRU,          "pablo_blk_AdvanceThenScanThru");
     26        b2k2CCode.put(B2KBuiltins.FLOW_ADVANCE_THEN_SCAN_TO,            "pablo_blk_AdvanceThenScanTo");
     27        b2k2CCode.put(B2KBuiltins.FLOW_SPAN_UP_TO,                      "pablo_blk_SpanUpTo");
     28        b2k2CCode.put(B2KBuiltins.FLOW_INCLUSIVE_SPAN,                  "pablo_blk_InclusiveSpan");
     29        b2k2CCode.put(B2KBuiltins.FLOW_EXCLUSIVE_SPAN,                  "pablo_blk_ExclusiveSpan");   
     30        b2k2CCode.put(B2KBuiltins.FLOW_ADVANCE_N,                       "pablo_blk_Advance_n_<%s>");
     31        b2k2CCode.put(B2KBuiltins.FLOW_MASK,                            "Mask");
     32        b2k2CCode.put(B2KBuiltins.FLOW_AT_EOF,                          "atEOF");
     33        b2k2CCode.put(B2KBuiltins.FLOW_IN_FILE,                         "inFile");
     34        b2k2CCode.put(B2KBuiltins.FLOW_ASSERT_ZERO,                     "assert_0_error");     
     35        b2k2CCode.put(B2KBuiltins.NULL_BUILTIN,                         "null_builtin_error");         
     36               
     37        b2k2CCode.put(B2KBuiltins._PRINT_BITBLOCK,                                      "print_register<BitBlock>");
     38        b2k2CCode.put(B2KBuiltins._ASSERT_BITBLOCK_ALIGN,                       "assert_bitblock_align");
     39        b2k2CCode.put(B2KBuiltins._EOF_MASK,                                            "EOF_mask");
     40        b2k2CCode.put(KernelBuiltins.DO_BLOCK,                                          "do_block");
     41        b2k2CCode.put(KernelBuiltins.DO_FINAL_BLOCK,                            "do_final_block");
     42        b2k2CCode.put(KernelBuiltins.CLEAR,                                             "clear");
    2043
    21         for(B2KBuiltin builtin : B2KBuiltin.values()) {
     44        List<B2KBuiltin> all_builtins = new ArrayList<B2KBuiltin>();
     45        all_builtins.addAll(Arrays.asList(B2KBuiltins.values()));
     46        all_builtins.addAll(Arrays.asList(KernelBuiltins.values()));
     47       
     48        for(B2KBuiltin builtin : all_builtins) {
    2249                if(!b2k2CCode.containsKey(builtin)) {
    23                                 throw new RuntimeException("S2K builtin to C mapping not unimplemented in :" + B2KBuiltins2C.class.getSimpleName());
     50                                throw new RuntimeException("B2K builtin to C mapping not unimplemented in :" + B2KBuiltins2C.class.getSimpleName());
    2451                }
    2552        }
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/B2KBuiltins2CPP.java

    r3797 r3820  
    11package toolchain.b2k.lang;
    22
     3import java.util.ArrayList;
     4import java.util.Arrays;
    35import java.util.HashMap;
     6import java.util.List;
    47import java.util.Map;
    58
    6 public class B2KBuiltins2CPP extends AbstractBuiltinEncoder {
     9
     10public class B2KBuiltins2CPP extends AbstractB2KBuiltinsEncoder {
    711       
    812        private static Map<B2KBuiltin, String> b2k2CPPCode;
     
    1216        b2k2CPPCode = new HashMap<B2KBuiltin, String>();
    1317       
    14         b2k2CPPCode.put(B2KBuiltin.PRINT_BITBLOCK, "print_register<BitBlock>");
    15         b2k2CPPCode.put(B2KBuiltin.ASSERT_BITBLOCK_ALIGN, "assert_bitblock_align");
    16         b2k2CPPCode.put(B2KBuiltin.EOF_MASK, "EOF_mask");
    17         b2k2CPPCode.put(B2KBuiltin.DO_BLOCK, "do_block");
    18         b2k2CPPCode.put(B2KBuiltin.DO_FINAL_BLOCK, "do_final_block");
    19         b2k2CPPCode.put(B2KBuiltin.CLEAR, "clear");
     18        // Flow
     19        b2k2CPPCode.put(B2KBuiltins.FLOW_ADVANCE,                       "pablo_blk_Advance");
     20        b2k2CPPCode.put(B2KBuiltins.FLOW_SCAN_TO_FIRST,                 "pablo_blk_ScanToFirst");
     21        b2k2CPPCode.put(B2KBuiltins.FLOW_SCAN_THRU,                     "pablo_blk_ScanThru");
     22        b2k2CPPCode.put(B2KBuiltins.FLOW_SCAN_TO,                       "pablo_blk_ScanTo");
     23        b2k2CPPCode.put(B2KBuiltins.FLOW_ADVANCE_THEN_SCAN_THRU,        "pablo_blk_AdvanceThenScanThru");
     24        b2k2CPPCode.put(B2KBuiltins.FLOW_ADVANCE_THEN_SCAN_TO,          "pablo_blk_AdvanceThenScanTo");
     25        b2k2CPPCode.put(B2KBuiltins.FLOW_SPAN_UP_TO,                    "pablo_blk_SpanUpTo");
     26        b2k2CPPCode.put(B2KBuiltins.FLOW_INCLUSIVE_SPAN,                "pablo_blk_InclusiveSpan");
     27        b2k2CPPCode.put(B2KBuiltins.FLOW_EXCLUSIVE_SPAN,                "pablo_blk_ExclusiveSpan");   
     28        b2k2CPPCode.put(B2KBuiltins.FLOW_ADVANCE_N,                     "pablo_blk_Advance_n_<%s>");
     29        b2k2CPPCode.put(B2KBuiltins.FLOW_MASK,                          "Mask");
     30        b2k2CPPCode.put(B2KBuiltins.FLOW_AT_EOF,                        "atEOF");
     31        b2k2CPPCode.put(B2KBuiltins.FLOW_IN_FILE,                       "inFile");
     32        b2k2CPPCode.put(B2KBuiltins.FLOW_ASSERT_ZERO,                   "assert_0_error");     
     33        b2k2CPPCode.put(B2KBuiltins.NULL_BUILTIN,                               "null_builtin_error");         
     34       
     35        // Empty package
     36        b2k2CPPCode.put(B2KBuiltins._PRINT_BITBLOCK,                                    "print_register<BitBlock>");
     37        b2k2CPPCode.put(B2KBuiltins._ASSERT_BITBLOCK_ALIGN,                     "assert_bitblock_align");
     38        b2k2CPPCode.put(B2KBuiltins._EOF_MASK,                                                  "EOF_mask");
     39        b2k2CPPCode.put(KernelBuiltins.DO_BLOCK,                                                "do_block");
     40        b2k2CPPCode.put(KernelBuiltins.DO_FINAL_BLOCK,                                  "do_final_block");
     41        b2k2CPPCode.put(KernelBuiltins.CLEAR,                                                   "clear");
    2042               
    21         for(B2KBuiltin builtin : B2KBuiltin.values()) {
     43        List<B2KBuiltin> all_builtins = new ArrayList<B2KBuiltin>();
     44        all_builtins.addAll(Arrays.asList(B2KBuiltins.values()));
     45        all_builtins.addAll(Arrays.asList(KernelBuiltins.values()));
     46       
     47        for(B2KBuiltin builtin : all_builtins) {
    2248                if(!b2k2CPPCode.containsKey(builtin)) {
    23                                 throw new RuntimeException("S2K builtin to C mapping not unimplemented in :" + B2KBuiltins2C.class.getSimpleName());
     49                                throw new RuntimeException("B2K builtin to CPP mapping not unimplemented in :" + B2KBuiltins2CPP.class.getSimpleName());
    2450                }
    2551        }
     
    3056                return b2k2CPPCode.get(builtin);
    3157        }
     58
    3259       
    3360}
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/KernelState.java

    r3699 r3820  
    33public enum KernelState {
    44
    5         CARRY1_INITIAL_VALUES("Carry1InitialValues"),
    6         CARRYN_INITIAL_VALUES("CarryNInitialValues"),
    7         CARRY1_COUNT("Carry1Count"),
    8         CARRYN_COUNT("CarryNCount"),
    9         LOOK_AHEAD("LookAhead"),
    10         LOOK_BEHIND("LookBehind");
     5        CARRY1_INITIAL_VALUES   ("Carry1InitialValues"),
     6        CARRYN_INITIAL_VALUES   ("CarryNInitialValues"),
     7        CARRY1_COUNT                    ("Carry1Count"),
     8        CARRYN_COUNT                    ("CarryNCount"),
     9        LOOK_AHEAD                              ("LookAhead"),
     10        LOOK_BEHIND                             ("LookBehind");
    1111       
    1212        private final String name;
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/type/PrimitiveType.java

    r3813 r3820  
    1313public enum PrimitiveType implements Type {
    1414
    15         VOID(),
    16         INTEGERCONSTANT(),
    17         STRINGCONSTANT(),
    18         BOOL(),
    19         BITFIELD() {
     15        VOID,
     16        INTEGER,
     17        STRING,
     18        BOOL,
     19        BITFIELD {
    2020                @Override public String toString() { return "BitField"; }
    2121        },      // power-of-2 bit field
    22         BITBLOCK(){
     22        BITBLOCK{
    2323                @Override public String toString() { return "BitBlock"; }
    2424        }, // SIMD vector size
    25         BITBLOCK_POINTER(),
    26         NO_TYPE (),     // use as a value when no type has been assigned
    27         NO_MATCH(),     // use as a (unified) value for non-matching types
     25        BITBLOCK_POINTER,
     26        NO_TYPE ,       // use as a value when no type has been assigned
     27        NO_MATCH,       // use as a (unified) value for non-matching types
    2828        ERROR() {       // use as a value when a syntax error has occurred
    2929        /*
     
    3434        };
    3535
    36         public static final int BITBLOCK_SIZE = 128; // TODO - KH: hoist to application level
    3736        private static final boolean ALL_TYPES_ACCEPT_ERROR_TYPES = true;
    3837               
  • proto/s2k/trunk/framework/src/toolchain/b2k/lang/type/Type.java

    r3813 r3820  
    2828         */
    2929        public Type getConcreteType();
     30       
     31        public static final int BITBLOCK_SIZE = 128; // TODO - KH: hoist to application level
    3032}
    3133
Note: See TracChangeset for help on using the changeset viewer.