├── .gitignore ├── Documentation └── Thesis.pdf ├── README.md ├── LICENSE ├── Init.clp ├── config.clp ├── lib.clp └── types.clp /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.bc 3 | a.out 4 | -------------------------------------------------------------------------------- /Documentation/Thesis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DrItanium/WavefrontScheduling/HEAD/Documentation/Thesis.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is one half of my masters thesis. The objective of which was to apply 2 | wavefront scheduling to superscalar processors. The other aspect required is 3 | LibExpertSystem. I have kept them separate because they are technically 4 | standalone. 5 | 6 | However, this code will NOT work in a standard clips build. There are functions 7 | defined in LibExpertSystem that this implementation requires. 8 | 9 | Whoever you are, I hope you enjoy perusing through this code. It was a lot of 10 | fun to write. 11 | 12 | The only requirement I have is that you MUST use clips 630 beta or higher. I 13 | use the foreach statement in several parts (11th hour change....) which was 14 | introduced in 630. 15 | 16 | At this point, using the expert system is a very manual process. You have to 17 | place the ExpertSystem.so (on linux) in the same folder as the CLIPS source 18 | code. I have been looking into preloading structures but CLIPS has not been 19 | playing nice. So at this point you need to run this optimization with opt. 20 | There is no integration with clang or anything like that. 21 | 22 | -Joshua Scoggins 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | WavefrontScheduling 2 | Copyright (c) 2012-2015, Joshua Scoggins 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY 17 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /Init.clp: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------ 2 | ;Copyright (c) 2012-2015, Joshua Scoggins 3 | ;All rights reserved. 4 | ; 5 | ;Redistribution and use in source and binary forms, with or without 6 | ;modification, are permitted provided that the following conditions are met: 7 | ; * Redistributions of source code must retain the above copyright 8 | ; notice, this list of conditions and the following disclaimer. 9 | ; * Redistributions in binary form must reproduce the above copyright 10 | ; notice, this list of conditions and the following disclaimer in the 11 | ; documentation and/or other materials provided with the distribution. 12 | ; 13 | ;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | ;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | ;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY 17 | ;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | ;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | ;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | ;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | ;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | ;------------------------------------------------------------------------------ 24 | ;Init.clp - the entry point to the code :) 25 | ;------------------------------------------------------------------------------ 26 | (batch-load (create$ "lib.clp" "types.clp" "config.clp" "logic.clp")) 27 | -------------------------------------------------------------------------------- /config.clp: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------ 2 | ;Copyright (c) 2012-2015, Joshua Scoggins 3 | ;All rights reserved. 4 | ; 5 | ;Redistribution and use in source and binary forms, with or without 6 | ;modification, are permitted provided that the following conditions are met: 7 | ; * Redistributions of source code must retain the above copyright 8 | ; notice, this list of conditions and the following disclaimer. 9 | ; * Redistributions in binary form must reproduce the above copyright 10 | ; notice, this list of conditions and the following disclaimer in the 11 | ; documentation and/or other materials provided with the distribution. 12 | ; 13 | ;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | ;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | ;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY 17 | ;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | ;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | ;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | ;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | ;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | ;------------------------------------------------------------------------------ 24 | ; config.clp - Contains the "switches" used to enable different aspects of 25 | ; debugging 26 | ;------------------------------------------------------------------------------ 27 | ;If you want to do things that occur at start up then make 28 | ; the changes here :). Uncomment the line below to enable debug mode :D 29 | 30 | (deffacts debug-stats 31 | ;(Debug) 32 | ;(Profile) 33 | ;(Rules) 34 | ;(Blocks) 35 | ;(Children) 36 | ;(Separator) 37 | ;(Paths) 38 | ;(Loop) 39 | ;(Facts) 40 | ;(RunStatistics) 41 | ;(Memory) 42 | ) 43 | (defrule GetInitialMemoryConsumption 44 | (Debug) 45 | (Memory) 46 | => 47 | (printout t "Initial Memory Consumption " (/ (mem-used) 131072) " MB" crlf)) 48 | 49 | (defrule GetRunStatistics 50 | (Debug) 51 | (RunStatistics) 52 | => 53 | (watch statistics)) 54 | (defrule WatchRules 55 | (Debug) 56 | (Rules) 57 | => 58 | (watch rules)) 59 | 60 | (defrule ProfileConstructs 61 | (Debug) 62 | (Profile) 63 | => 64 | (profile-reset) 65 | (profile constructs) 66 | (set-profile-percent-threshold 1)) 67 | -------------------------------------------------------------------------------- /lib.clp: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------ 2 | ;Copyright (c) 2012-2015, Joshua Scoggins 3 | ;All rights reserved. 4 | ; 5 | ;Redistribution and use in source and binary forms, with or without 6 | ;modification, are permitted provided that the following conditions are met: 7 | ; * Redistributions of source code must retain the above copyright 8 | ; notice, this list of conditions and the following disclaimer. 9 | ; * Redistributions in binary form must reproduce the above copyright 10 | ; notice, this list of conditions and the following disclaimer in the 11 | ; documentation and/or other materials provided with the distribution. 12 | ; 13 | ;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | ;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | ;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY 17 | ;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | ;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | ;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | ;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | ;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | ;------------------------------------------------------------------------------ 24 | ; lib.clp - Contains set operations such as superset and equality 25 | ;------------------------------------------------------------------------------ 26 | (deffunction superset (?a ?b) 27 | (and (>= (length$ ?a) (length$ ?b)) 28 | (subsetp ?b ?a) (not (subsetp ?a ?b)))) 29 | ;------------------------------------------------------------------------------ 30 | (deffunction equal$ (?a ?b) 31 | (and 32 | (= (length$ ?a) (length$ ?b)) 33 | (subsetp ?b ?a) 34 | (subsetp ?a ?b))) 35 | ;------------------------------------------------------------------------------ 36 | (deffunction has-common-element (?a ?b) 37 | (progn$ (?c ?a) 38 | (if (member$ ?c ?b) then (return TRUE))) 39 | (return FALSE)) 40 | ;------------------------------------------------------------------------------ 41 | (deffunction disjoint (?a ?b) 42 | (not (has-common-element ?a ?b))) 43 | ;------------------------------------------------------------------------------ 44 | (deffunction symbol-to-pointer-list 45 | "Converts a given list of symbols that represent InteropObjects and pulls the 46 | pointer value out of it. This function assumes order is important" 47 | (?list) 48 | (bind ?result (create$)) 49 | (progn$ (?e ?list) 50 | (bind ?obj (symbol-to-instance-name ?e)) 51 | (bind ?result (create$ ?result (send ?obj get-Pointer)))) 52 | (return ?result)) 53 | ;------------------------------------------------------------------------------ 54 | -------------------------------------------------------------------------------- /types.clp: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------ 2 | ;Copyright (c) 2012-2015, Joshua Scoggins 3 | ;All rights reserved. 4 | ; 5 | ;Redistribution and use in source and binary forms, with or without 6 | ;modification, are permitted provided that the following conditions are met: 7 | ; * Redistributions of source code must retain the above copyright 8 | ; notice, this list of conditions and the following disclaimer. 9 | ; * Redistributions in binary form must reproduce the above copyright 10 | ; notice, this list of conditions and the following disclaimer in the 11 | ; documentation and/or other materials provided with the distribution. 12 | ; 13 | ;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | ;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | ;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY 17 | ;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | ;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | ;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | ;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | ;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | ;------------------------------------------------------------------------------ 24 | ; Types.clp - contains all of the types used by wavefront scheduling 25 | ;------------------------------------------------------------------------------ 26 | (defclass TaggedObject (is-a USER) 27 | (slot Class (visibility public) (type SYMBOL)) 28 | (slot ID (visibility public) (type SYMBOL)) 29 | (slot Parent (visibility public) (default-dynamic nil))) 30 | 31 | (defmessage-handler TaggedObject init after () 32 | (bind ?self:ID (instance-name-to-symbol (instance-name ?self))) 33 | (bind ?self:Class (class ?self))) 34 | ;------------------------------------------------------------------------------ 35 | (defclass PathAggregate 36 | "The PathAggregate is a very useful data structure that keeps track of all 37 | information regarding paths and scheduling for a given block on the wavefront. 38 | Like all objects in this project, it is a tagged object so that it can be 39 | easily queried without knowing it's name directly. " 40 | (is-a TaggedObject) 41 | (slot OriginalStopIndex (type NUMBER)) 42 | (multislot MemoryInvalid (visibility public)) 43 | (multislot MemoryValid (visibility public)) 44 | (multislot PotentiallyValid (visibility public)) 45 | (multislot MemoryBarriers (visibility public)) 46 | (multislot CallBarriers (visibility public)) 47 | (multislot CompletelyInvalid (visibility public)) 48 | ;compensation path vector aspect of the PathAggregate 49 | (multislot InstructionList (visibility public)) 50 | (multislot ReplacementActions (visibility public)) 51 | (multislot InstructionPropagation (visibility public)) 52 | (multislot ScheduledInstructions (visibility public)) 53 | (multislot CompensationPathVectors (visibility public)) 54 | (multislot TargetCompensationPathVectors (visibility public)) 55 | (multislot MovableCompensationPathVectors (visibility public)) 56 | (multislot ImpossibleCompensationPathVectors (visibility public)) 57 | (multislot StalledCompensationPathVectors (visibility public))) 58 | ;------------------------------------------------------------------------------ 59 | (defclass Slice (is-a TaggedObject) 60 | (slot TargetBlock (type SYMBOL) (visibility public)) 61 | (slot TargetPath (type SYMBOL) (visibility public)) 62 | (multislot Contents (visibility public))) 63 | ;------------------------------------------------------------------------------ 64 | ; An InteropObject stores a pointer to a type outside CLIPS 65 | ;------------------------------------------------------------------------------ 66 | (defclass InteropObject (is-a USER) 67 | (slot Pointer (visibility public) (type NUMBER))) 68 | ;------------------------------------------------------------------------------ 69 | (defclass LLVMObject (is-a TaggedObject InteropObject) 70 | (slot Name (visibility public)) 71 | (multislot WritesTo (visibility public)) 72 | (multislot ReadsFrom (visibility public))) 73 | ;------------------------------------------------------------------------------ 74 | (defclass Diplomat 75 | "A Diplomat is a collection of fields that interact with other 76 | objects." 77 | (is-a LLVMObject) 78 | (slot IsOpen (type SYMBOL) (visibility public) 79 | (allowed-values FALSE TRUE)) 80 | (slot HasCallBarrier (type SYMBOL) (visibility public) 81 | (allowed-values FALSE TRUE)) 82 | (slot HasMemoryBarrier (type SYMBOL) (visibility public) 83 | (allowed-values FALSE TRUE)) 84 | (multislot PreviousPathElements (visibility public)) 85 | (multislot NextPathElements (visibility public)) 86 | (multislot Consumes) 87 | (multislot Produces) 88 | ;(multislot Chokes (visibility public)) 89 | ;(multislot ChokedBy (visibility public)) 90 | (multislot Paths (visibility public))) 91 | ;(multislot RegionalAllies (visibility public)) 92 | ;(multislot FunctionalAllies (visibility public))) 93 | 94 | ;(defmessage-handler Diplomat .AddRegionalAlly (?a) 95 | ; (bind ?self:RegionalAllies (create$ ?self:RegionalAllies ?a))) 96 | ; 97 | ;(defmessage-handler Diplomat .AddFunctionalAlly (?a) 98 | ; (bind ?self:FunctionalAllies (create$ ?self:FunctionalAllies ?a))) 99 | 100 | ;(defmessage-handler Diplomat .AddPath (?path) 101 | ; (bind ?self:Paths (create$ ?self:Paths ?path))) 102 | 103 | ;(defmessage-handler Diplomat .AddChokes (?blk) 104 | ; (bind ?self:Chokes (create$ ?self:Chokes ?blk))) 105 | ; 106 | ;(defmessage-handler Diplomat .AddChokedBy (?blk) 107 | ; (bind ?self:ChokedBy (create$ ?self:ChokedBy ?blk))) 108 | 109 | ;------------------------------------------------------------------------------ 110 | (defclass List (is-a TaggedObject) 111 | (slot Length (type NUMBER) (default-dynamic 0)) 112 | (multislot Contents (visibility public))) 113 | 114 | (defmessage-handler List .Add (?element) 115 | (slot-direct-insert$ Contents (+ ?self:Length 1) ?element) 116 | (bind ?self:Length (+ ?self:Length 1))) 117 | 118 | (defmessage-handler List .AddBefore (?point ?element) 119 | (bind ?ind (nth$ ?point ?self:Contents)) 120 | (slot-direct-insert$ Contents ?ind ?element) 121 | (bind ?self:Length (+ 1 ?self:Length))) 122 | 123 | (defmessage-handler List .AddAfter (?point ?element) 124 | (bind ?ind (+ 1 (nth$ ?point ?self:Contents))) 125 | (slot-direct-insert$ Contents ?ind ?element) 126 | (bind ?self:Length (+ 1 ?self:Length))) 127 | 128 | (defmessage-handler List .Remove (?element) 129 | (bind ?self:Length (- ?self:Length 1)) 130 | (bind ?self:Contents (delete-member$ ?self:Contents ?element))) 131 | 132 | (defmessage-handler List .RemoveAt (?index) 133 | (bind ?self:Contents (- ?self:Length 1)) 134 | (slot-direct-delete$ Contents ?index ?index)) 135 | 136 | 137 | (defmessage-handler List .AddRangeAt (?index $?elements) 138 | (slot-direct-insert$ Contents ?index $?elements)) 139 | 140 | (defmessage-handler List .ElementAt (?index) 141 | (nth$ ?index ?self:Contents)) 142 | 143 | (defmessage-handler List .Contains (?item) 144 | (neq (member$ ?item ?self:Contents) FALSE)) 145 | 146 | (defmessage-handler List .ContainsSubset ($?subset) 147 | (subsetp ?subset ?self:Contents)) 148 | ;------------------------------------------------------------------------------ 149 | (defclass LLVMType (is-a LLVMObject) 150 | (slot IsVoidType (type SYMBOL) (allowed-values FALSE TRUE)) 151 | (slot IsHalfType (type SYMBOL) (allowed-values FALSE TRUE)) 152 | (slot IsFloatType (type SYMBOL) (allowed-values FALSE TRUE)) 153 | (slot IsDoubleType (type SYMBOL) (allowed-values FALSE TRUE)) 154 | (slot IsX86FP80Type (type SYMBOL) (allowed-values FALSE TRUE)) 155 | (slot IsFP128Type (type SYMBOL) (allowed-values FALSE TRUE)) 156 | (slot IsPPCFP128Type (type SYMBOL) (allowed-values FALSE TRUE)) 157 | (slot IsFloatingPointType (type SYMBOL) (allowed-values FALSE TRUE)) 158 | (slot IsX86MMXType (type SYMBOL) (allowed-values FALSE TRUE)) 159 | (slot IsFPOrFPVectorType (type SYMBOL) (allowed-values FALSE TRUE)) 160 | (slot IsLabelType (type SYMBOL) (allowed-values FALSE TRUE)) 161 | (slot IsMetadataType (type SYMBOL) (allowed-values FALSE TRUE)) 162 | (slot IsIntegerType (type SYMBOL) (allowed-values FALSE TRUE)) 163 | (slot IsIntOrIntVectorType (type SYMBOL) (allowed-values FALSE TRUE)) 164 | (slot IsFunctionType (type SYMBOL) (allowed-values FALSE TRUE)) 165 | (slot IsStructType (type SYMBOL) (allowed-values FALSE TRUE)) 166 | (slot IsArrayType (type SYMBOL) (allowed-values FALSE TRUE)) 167 | (slot IsPointerType (type SYMBOL) (allowed-values FALSE TRUE)) 168 | (slot IsVectorType (type SYMBOL) (allowed-values FALSE TRUE)) 169 | (slot IsEmptyType (type SYMBOL) (allowed-values FALSE TRUE)) 170 | (slot IsPrimitiveType (type SYMBOL) (allowed-values FALSE TRUE)) 171 | (slot IsDerivedType (type SYMBOL) (allowed-values FALSE TRUE)) 172 | (slot IsFirstClassType (type SYMBOL) (allowed-values FALSE TRUE)) 173 | (slot IsSingleValueType (type SYMBOL) (allowed-values FALSE TRUE)) 174 | (slot IsAggregateType (type SYMBOL) (allowed-values FALSE TRUE)) 175 | (slot IsSized (type SYMBOL) (allowed-values FALSE TRUE)) 176 | (slot PrimitiveSizeInBits (type NUMBER) (range 0 ?VARIABLE)) 177 | (slot ScalarSizeInBits (type NUMBER) (range 0 ?VARIABLE)) 178 | (slot FPMantissaWidth (type NUMBER) (range 0 ?VARIABLE)) 179 | (slot ScalarType (allowed-classes LLVMType)) 180 | (multislot Subtypes) 181 | (multislot TypeMakeup (type SYMBOL)) 182 | (slot IsFunctionVarArg (type SYMBOL) (allowed-values FALSE TRUE)) 183 | (slot QuickType (type SYMBOL))) 184 | 185 | (defclass IntegerType (is-a LLVMType) 186 | (slot BitWidth (type NUMBER) (range 0 ?VARIABLE)) 187 | (slot BitMask (type NUMBER)) 188 | (slot SignBit (type NUMBER)) 189 | (slot IsPowerOf2ByteWidth (type SYMBOL) (allowed-values FALSE TRUE))) 190 | 191 | (defclass FunctionType (is-a LLVMType) 192 | (slot IsVarArg (type SYMBOL) (allowed-values FALSE TRUE)) 193 | (slot ReturnType (allowed-classes LLVMType)) 194 | (multislot Parameters)) 195 | 196 | 197 | (defmessage-handler FunctionType GetNumParams () 198 | (length ?self:Parameters)) 199 | 200 | (defmessage-handler FunctionType GetParamType (?index) 201 | (nth$ ?index ?self:Parameters)) 202 | 203 | (defclass CompositeType (is-a LLVMType) 204 | (multislot Indicies)) 205 | 206 | (defclass StructType (is-a CompositeType) 207 | (slot Name (type SYMBOL)) 208 | (slot IsPacked (type SYMBOL) (allowed-values FALSE TRUE)) 209 | (slot IsLiteral (type SYMBOL) (allowed-values FALSE TRUE)) 210 | (slot IsOpaque (type SYMBOL) (allowed-values FALSE TRUE)) 211 | (slot IsSized (type SYMBOL) (allowed-values FALSE TRUE)) 212 | (slot HasName (type SYMBOL) (allowed-values FALSE TRUE)) 213 | (multislot Body)) 214 | 215 | (defmessage-handler StructType SetBody (?element ?isPacked) 216 | (bind ?self:IsPacked ?isPacked) 217 | (bind ?self:Body ?element)) 218 | 219 | (defmessage-handler StructType SetBody$ ($?types) 220 | (bind ?self:Body (create$ ?self:Body ?types))) 221 | 222 | (defmessage-handler StructType GetNumElements () 223 | (length ?self:Body)) 224 | 225 | (defmessage-handler StructType Elements () 226 | (return ?self:Body)) 227 | 228 | (defmessage-handler StructType GetElementType (?n) 229 | (if (> ?n (length ?self:Body)) then 230 | (printout t "ERROR: Element out of range for message GetElementType of StructType!" crlf) 231 | (exit) 232 | else 233 | (return (nth$ ?n ?self:Body)))) 234 | 235 | (defclass SequentialType (is-a CompositeType) 236 | (slot ElementType (allowed-classes LLVMType))) 237 | 238 | (defclass VectorType (is-a SequentialType) 239 | (slot BitWidth (type NUMBER) (range 0 ?VARIABLE)) 240 | (slot NumElements (type NUMBER) (range 0 ?VARIABLE))) 241 | 242 | (defclass PointerType (is-a SequentialType) 243 | (slot AddressSpace (type NUMBER) (range 0 ?VARIABLE))) 244 | 245 | (defclass ArrayType (is-a SequentialType) 246 | (slot NumElements (type NUMBER) (range 0 ?VARIABLE))) 247 | 248 | ;------------------------------------------------------------------------------ 249 | (defclass LLVMValue (is-a LLVMObject) 250 | (slot HasAddressTaken (type SYMBOL) (allowed-values FALSE TRUE)) 251 | (slot IsLandingPad (type SYMBOL) (allowed-values FALSE TRUE)) 252 | (slot HasOneUse (type SYMBOL) (allowed-values FALSE TRUE)) 253 | (slot NumberOfUses (type NUMBER) (range 0 ?VARIABLE)) 254 | (slot Type (visibility public)) 255 | ;(slot Name (type STRING)) 256 | (slot ValueName) 257 | (multislot Users) 258 | (slot ValueID (type NUMBER) (range 0 ?VARIABLE)) 259 | (slot RawSubclassOptionalData (type NUMBER) (range 0 ?VARIABLE)) 260 | (slot HasValueHandle (type SYMBOL) (allowed-values FALSE TRUE)) 261 | (slot IsDereferenceablePointer (type SYMBOL) (allowed-values FALSE TRUE))) 262 | 263 | 264 | ;(defmessage-handler LLVMValue HasName () 265 | ; (return (> (str-length ?self:Name) 0))) 266 | (defmessage-handler LLVMValue GetNumUses () 267 | (length ?self:Users)) 268 | (defmessage-handler LLVMValue HasNUses (?n) 269 | (= ?n (length ?self:Users))) 270 | (defmessage-handler LLVMValue HasNUsesOrMore (?n) 271 | (>= ?n (length ?self:Users))) 272 | (defmessage-handler LLVMValue HasSameSubclassOptionalData (?v) 273 | (= ?self:RawSubclassOptionalData (send ?v get-RawSubclassOptionalData))) 274 | ;------------------------------------------------------------------------------ 275 | (defclass Argument (is-a LLVMValue) 276 | (slot Index (type NUMBER) (range 0 ?VARIABLE)) 277 | (slot HasByValueAttribute (type SYMBOL) (allowed-values FALSE TRUE)) 278 | (slot ParameterAlignment (type NUMBER) (range 0 ?VARIABLE)) 279 | (slot HasNestAttribute (type SYMBOL) (allowed-values FALSE TRUE)) 280 | (slot HasNoAliasAttribute (type SYMBOL) (allowed-values FALSE TRUE)) 281 | (slot HasNoCaptureAttribute (type SYMBOL) (allowed-values FALSE TRUE)) 282 | (slot HasStructRetAttribute (type SYMBOL) (allowed-values FALSE TRUE)) 283 | (multislot Attributes)) 284 | ;------------------------------------------------------------------------------ 285 | (defclass LLVMUser (is-a LLVMValue) 286 | (multislot Operands (visibility public))) 287 | 288 | (defmessage-handler LLVMUser .AddOperand (?op) 289 | (bind ?self:Operands (create$ ?self:Operands ?op))) 290 | (defmessage-handler LLVMUser .AddOperands ($?ops) 291 | (bind ?self:Operands (create$ ?self:Operands ?ops))) 292 | 293 | ;------------------------------------------------------------------------------ 294 | (defclass LLVMInlineAsm (is-a LLVMValue) 295 | (slot HasSideEffects (type SYMBOL) (allowed-values FALSE TRUE)) 296 | (slot IsAlignStack (type SYMBOL) (allowed-values FALSE TRUE)) 297 | (slot FunctionType (allowed-classes LLVMType)) 298 | (slot AsmString (type STRING)) 299 | (slot ConstraintString (type STRING))) 300 | 301 | ;------------------------------------------------------------------------------ 302 | (defclass LLVMMDNode (is-a LLVMValue) 303 | (multislot Operands) 304 | (slot IsFunctionLocal (type SYMBOL) (allowed-values FALSE TRUE)) 305 | (slot TargetFunction (type SYMBOL))) 306 | (defclass LLVMMDString (is-a LLVMValue) 307 | (slot String (type STRING))) 308 | ;------------------------------------------------------------------------------ 309 | (defclass DependencyChain (is-a TaggedObject) 310 | (slot Producers (default-dynamic (make-instance (gensym*) of List))) 311 | (slot Consumers (default-dynamic (make-instance (gensym*) of List)))) 312 | 313 | (defmessage-handler DependencyChain init after () 314 | (bind ?id (send ?self get-ID)) 315 | (send ?self:Producers put-Parent ?id) 316 | (send ?self:Consumers put-Parent ?id)) 317 | (defmessage-handler DependencyChain .ProducerCount () 318 | (send ?self:Producers .Count)) 319 | (defmessage-handler DependencyChain .ConsumerCount () 320 | (send ?self:Consumers .Count)) 321 | (defmessage-handler DependencyChain .AddProducers ($?p) 322 | (send ?self:Producers .AddRange ?p)) 323 | (defmessage-handler DependencyChain .AddProducer (?p) 324 | "Adds a producer to the list of producers" 325 | (send ?self:Producers .SetAdd ?p)) 326 | (defmessage-handler DependencyChain .AddConsumer (?p) 327 | "Adds a producer to the list of consumers" 328 | (send ?self:Consumers .SetAdd ?p)) 329 | 330 | (defmessage-handler DependencyChain .AddConsumers ($?s) 331 | (send ?self:Consumers .AddRange ?s)) 332 | 333 | (defmessage-handler DependencyChain .IsProducer (?p) 334 | (send ?self:Producers .Contains ?p)) 335 | 336 | (defmessage-handler DependencyChain .IsConsumer (?p) 337 | (send ?self:Consumers .Contains ?p)) 338 | 339 | (defmessage-handler DependencyChain .HasProducers () 340 | (not (send ?self:Producers .IsEmpty))) 341 | 342 | (defmessage-handler DependencyChain .HasConsumers () 343 | (not (send ?self:Consumers .IsEmpty))) 344 | 345 | (defmessage-handler DependencyChain .RemoveConsumer (?v) 346 | (send ?self:Consumers .Remove ?v)) 347 | 348 | (defmessage-handler DependencyChain .RemoveProducer (?v) 349 | (send ?self:Producers .Remove ?v)) 350 | 351 | (defmessage-handler DependencyChain .ProducersContainsSubset ($?v) 352 | (send ?self:Producers .ContainsSubset $?v)) 353 | 354 | (defmessage-handler DependencyChain .ConsumersContainsSubset ($?v) 355 | (send ?self:Consumers .ContainsSubset $?v)) 356 | 357 | (defmessage-handler DependencyChain .Producers () 358 | "Returns the list of producers from the dependency information" 359 | (return (send ?self:Producers get-Contents))) 360 | 361 | (defmessage-handler DependencyChain .Consumers () 362 | "Returns the list of consumers from the dependency information" 363 | (return (send ?self:Consumers get-Contents))) 364 | 365 | ;------------------------------------------------------------------------------ 366 | (defclass InstructionGroup (is-a TaggedObject) 367 | (multislot Contents (visibility public)) 368 | (slot TimeIndex (type NUMBER) (visibility public))) 369 | ;------------------------------------------------------------------------------ 370 | (defclass Constant (is-a LLVMUser) 371 | (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE)) 372 | (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE)) 373 | (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE)) 374 | (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE)) 375 | (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE)) 376 | (slot RelocationInfo (type SYMBOL) (default nil) (allowed-symbols nil NoRelocations 377 | LocalRelocation GlobalRelocations))) 378 | 379 | (defmessage-handler Constant init after () 380 | (bind ?self:Type Constant)) 381 | 382 | (defclass BlockAddress (is-a Constant) 383 | (slot TargetBlock (type SYMBOL))) 384 | (defclass ConstantAggregateZero (is-a Constant) 385 | (slot Element (type SYMBOL))) 386 | (defclass ConstantArray (is-a Constant)) 387 | (defclass ConstantDataSequential (is-a Constant) 388 | (multislot Elements) 389 | (slot ElementType (type SYMBOL)) 390 | (slot ElementCount (type NUMBER) (range 0 ?VARIABLE)) 391 | (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE)) 392 | (slot IsString (type SYMBOL) (allowed-values FALSE TRUE)) 393 | (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE))) 394 | 395 | (defclass ConstantDataArray (is-a ConstantDataSequential)) 396 | (defclass ConstantDataVector (is-a ConstantDataSequential)) 397 | (defclass ConstantExpression (is-a Constant) 398 | (slot Operation) 399 | (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE)) 400 | (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE)) 401 | (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE)) 402 | (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL) (allowed-values FALSE TRUE)) 403 | (slot Opcode (type NUMBER) (range 0 ?VARIABLE)) 404 | (slot Predicate (type NUMBER) (range 0 ?VARIABLE)) 405 | (multislot Indices) 406 | (slot OpcodeName (type SYMBOL))) 407 | 408 | (defclass BinaryConstantExpression (is-a ConstantExpression)) 409 | (defclass CompareConstantExpression (is-a ConstantExpression) 410 | (slot Predicate (type NUMBER))) 411 | 412 | (defclass ConstantFloatingPoint (is-a Constant) 413 | (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE)) 414 | (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE)) 415 | (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE)) 416 | (slot Value (type FLOAT)) 417 | ) 418 | ;TODO: IsExactlyValue calls 419 | 420 | (defclass ConstantInteger (is-a Constant) 421 | (slot ZeroExtendedValue (type NUMBER)) 422 | (slot SignExtendedValue (type NUMBER)) 423 | (slot Width (type NUMBER) (range 0 ?VARIABLE)) 424 | (slot Value (type SYMBOL NUMBER)) 425 | (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE)) 426 | (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE)) 427 | (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE)) 428 | (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE))) 429 | (defclass PointerConstant (is-a Constant) 430 | (slot PointerType (type SYMBOL))) 431 | (defclass ConstantPointerNull (is-a PointerConstant)) 432 | (defclass ConstantStruct (is-a PointerConstant)) 433 | (defclass ConstantVector (is-a PointerConstant) 434 | (slot SplatValue (type SYMBOL))) 435 | 436 | (defclass GlobalValue (is-a Constant) 437 | (slot Alignment (type NUMBER)) 438 | (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE)) 439 | (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE)) 440 | (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE)) 441 | (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE)) 442 | (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE)) 443 | (slot Section (type SYMBOL)) 444 | (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE)) 445 | (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 446 | (slot HasAvailableExternallyLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 447 | (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 448 | (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 449 | (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 450 | (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 451 | (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 452 | (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 453 | (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 454 | (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 455 | (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 456 | (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 457 | (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 458 | (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 459 | (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE)) 460 | (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE)) 461 | (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE)) 462 | (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE)) 463 | (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE)) 464 | (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE)) 465 | (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE)) 466 | (slot Initializer)) 467 | 468 | (defclass GlobalVariable (is-a GlobalValue) 469 | (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE)) 470 | (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE)) 471 | (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE)) 472 | (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE)) 473 | (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE))) 474 | (defclass GlobalAlias (is-a GlobalValue) 475 | (slot Aliasee)) 476 | 477 | (defclass UndefValue (is-a Constant)) 478 | 479 | 480 | ;------------------------------------------------------------------------------ 481 | (defclass Schedule (is-a TaggedObject) 482 | (multislot Contents (visibility public)) 483 | (multislot Scheduled (visibility public)) 484 | (multislot Success (visibility public)) 485 | (multislot Failure (visibility public)) 486 | (multislot InstructionStream (visibility public))) 487 | ;(multislot Groups (visibility public)) 488 | ; (slot TimeGenerator (type NUMBER) (default-dynamic 0))) 489 | 490 | (defmessage-handler Schedule .ScheduledContainsSubset (?a) 491 | (subsetp (create$ ?a) ?self:Scheduled)) 492 | (defmessage-handler Schedule .AddScheduledInstruction (?i) 493 | (bind ?self:Scheduled (create$ ?self:Scheduled ?i))) 494 | 495 | (defmessage-handler Schedule .MarkScheduled (?t ?ind) 496 | (slot-direct-insert$ Scheduled ?ind ?t) 497 | (slot-direct-delete$ Success ?ind ?ind) 498 | (slot-direct-insert$ InstructionStream (+ 1 (length$ ?self:Scheduled)) ?t)) 499 | 500 | (defmessage-handler Schedule .MarkStoreScheduled (?t ?s ?ind) 501 | (slot-direct-insert$ Scheduled ?ind ?t ?s) 502 | (slot-direct-delete$ Success ?ind ?ind) 503 | (slot-direct-insert$ InstructionStream (+ 1 (length$ ?self:Scheduled)) ?t)) 504 | 505 | 506 | 507 | ;------------------------------------------------------------------------------ 508 | ; Instruction.clp - Base LLVM Instruction class 509 | ;------------------------------------------------------------------------------ 510 | 511 | (defclass Instruction (is-a LLVMUser InteropObject) 512 | (slot NumSuccessors) 513 | (slot HasValueHandle (type SYMBOL) (allowed-values FALSE TRUE)) 514 | (slot IsDereferenceablePointer (type SYMBOL) (allowed-values FALSE TRUE)) 515 | (slot MayWriteToMemory (type SYMBOL) (allowed-values FALSE TRUE)) 516 | (slot MayReadFromMemory (type SYMBOL) (allowed-values FALSE TRUE)) 517 | (slot MayReadOrWriteMemory (type SYMBOL) (allowed-values FALSE TRUE)) 518 | (slot MayHaveSideEffects (type SYMBOL) (allowed-values FALSE TRUE)) 519 | (slot HasCallDependency (type SYMBOL) (allowed-values FALSE TRUE)) 520 | (slot IsBinaryOp (type SYMBOL) (allowed-values FALSE TRUE)) 521 | (slot IsTerminator (type SYMBOL) (allowed-values FALSE TRUE)) 522 | (slot IsShift (type SYMBOL) (allowed-values FALSE TRUE)) 523 | (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE)) 524 | (slot IsArithmeticShift (type SYMBOL) (allowed-values FALSE TRUE)) 525 | (slot IsLogicalShift (type SYMBOL) (allowed-values FALSE TRUE)) 526 | (slot IsAssociative (type SYMBOL) (allowed-values FALSE TRUE)) 527 | (slot IsCommutative (type SYMBOL) (allowed-values FALSE TRUE)) 528 | (slot Predicate (type SYMBOL)) 529 | (slot Operation (type SYMBOL)) 530 | (slot TimeIndex (type NUMBER) (default-dynamic 0)) 531 | ;(slot ExecutionLength (type NUMBER) (default-dynamic -1)) 532 | (slot MemoryTarget (type SYMBOL) (default-dynamic nil)) 533 | (multislot LocalDependencies) 534 | (multislot NonLocalDependencies) 535 | (multislot Consumers) 536 | (multislot Producers) 537 | (multislot DestinationRegisters)) 538 | ;(multislot SourceRegisters (visibility public))) 539 | ;(multislot BlocksUsedIn (visibility public))) 540 | ;(slot InstructionType (type SYMBOL) (default-dynamic nil))) 541 | ;------------------------------------------------------------------------------ 542 | ;(defmessage-handler Instruction init after () 543 | ;copy the Operands into SourceRegisters and Producers list 544 | ;this should save a ton of time... :D 545 | ;(bind ?self:SourceRegisters ?self:Operands) 546 | ;(bind ?self:Producers ?self:Operands)) 547 | ;------------------------------------------------------------------------------ 548 | (defmessage-handler Instruction .IncrementTimeIndex () 549 | (bind ?self:TimeIndex (+ 1 ?self:TimeIndex))) 550 | ;------------------------------------------------------------------------------ 551 | (defmessage-handler Instruction .DecrementTimeIndex () 552 | (bind ?self:TimeIndex (- ?self:TimeIndex 1))) 553 | ;------------------------------------------------------------------------------ 554 | ; Hint.clp - Contains the basic hint type plus a few ease of access sub types 555 | ; Hints are my way of quickly creating objects that map a single 556 | ; object to a series of other objects. A hint also contains a type 557 | ; field that allows hints to be further constrained by another type. 558 | ; Suprisingly enough hints are quite useful as they allow facts to 559 | ; be created with a minimal amount of effort yet are very expressive 560 | ; in their contents. 561 | ; 562 | ; They can also keep track of the number of references they have 563 | ;------------------------------------------------------------------------------ 564 | (defclass Hint (is-a List) 565 | (slot Type (visibility public) (default nil)) 566 | (slot Point (default nil)) 567 | (slot ReferenceCount (visibility public) (type NUMBER))) 568 | 569 | ;------------------------------------------------------------------------------ 570 | (defmessage-handler Hint .IncrementReferenceCount () 571 | (bind ?self:ReferenceCount (+ ?self:ReferenceCount 1))) 572 | ;------------------------------------------------------------------------------ 573 | (defmessage-handler Hint .DecrementReferenceCount () 574 | (bind ?self:ReferenceCount (- ?self:ReferenceCount 1))) 575 | ;------------------------------------------------------------------------------ 576 | (deffunction hints-of-type-with-point (?type ?point) 577 | "Gets all hints with the specified type and point" 578 | (find-all-instances ((?h Hint)) 579 | (and (eq ?type (send ?h get-Type)) 580 | (eq ?point (send ?h get-Point))))) 581 | ;------------------------------------------------------------------------------ 582 | (deffunction hints-of-type (?type) 583 | "Returns all hints of a given type" 584 | (find-all-instances ((?h Hint)) (eq ?type (send ?h get-Type)))) 585 | ;------------------------------------------------------------------------------ 586 | (deffunction hintp (?instance) 587 | (if (or (instance-namep ?instance) 588 | (instance-addressp ?instance)) then 589 | (bind ?conv ?instance) 590 | else 591 | (bind ?conv (symbol-to-instance-name ?instance))) 592 | (return (eq (class ?conv) Hint))) 593 | ;------------------------------------------------------------------------------ 594 | (defclass Path (is-a Hint) 595 | (slot ExitBlock (type SYMBOL)) 596 | (slot Closed (type SYMBOL) (allowed-values FALSE TRUE))) 597 | ;------------------------------------------------------------------------------ 598 | (defmessage-handler Path init after () 599 | (bind ?self:Type Path)) 600 | ;------------------------------------------------------------------------------ 601 | (defclass Hierarchy (is-a Hint)) 602 | ;------------------------------------------------------------------------------ 603 | (defmessage-handler Hierarchy init after () 604 | (bind ?self:Type Hierarchy)) 605 | ;------------------------------------------------------------------------------ 606 | (defclass FrequencyAnalysis (is-a Hint) 607 | (slot Frequency (type NUMBER) (range 0 ?VARIABLE))) 608 | ;------------------------------------------------------------------------------ 609 | (defmessage-handler FrequencyAnalysis init after () 610 | (bind ?self:Type FrequencyAnalysis)) 611 | ;------------------------------------------------------------------------------ 612 | (defmessage-handler FrequencyAnalysis .IncrementFrequency () 613 | (bind ?self:Frequency (+ 1 ?self:Frequency))) 614 | ;------------------------------------------------------------------------------ 615 | (defclass FlatList (is-a Hint)) 616 | ;------------------------------------------------------------------------------ 617 | (defmessage-handler FlatList init after () 618 | (bind ?self:Type FlatList)) 619 | ;------------------------------------------------------------------------------ 620 | (defclass Wavefront (is-a Hint) 621 | (multislot Open (visibility public)) 622 | (multislot DeleteNodes (visibility public)) 623 | (multislot Closed (visibility public))) 624 | 625 | (defmessage-handler Wavefront init after () 626 | (bind ?self:Type Wavefront)) 627 | ;------------------------------------------------------------------------------ 628 | (defclass MultiBlockContainer (is-a Diplomat List InteropObject) 629 | (multislot Entrances (visibility public)) 630 | (multislot Exits (visibility public)) 631 | (multislot SafePaths (visibility public)) 632 | (multislot Joins (visibility public)) 633 | (multislot Splits (visibility public))) 634 | 635 | (defmessage-handler MultiBlockContainer .AddBlock (?BLK) 636 | (bind ?self:Contents (create$ ?self:Contents ?BLK))) 637 | 638 | (defmessage-handler MultiBlockContainer .AddBlocks ($?blks) 639 | (bind ?self:Contents (create$ ?self:Contents ?blks))) 640 | 641 | (defmessage-handler MultiBlockContainer .AddEntrance (?BLK) 642 | (bind ?self:Entrances (create$ ?self:Entrances ?BLK))) 643 | 644 | (defmessage-handler MultiBlockContainer .AddExit (?BLK) 645 | (bind ?self:Exits (create$ ?self:Exits ?BLK))) 646 | 647 | (defmessage-handler MultiBlockContainer .AddSafePath (?BLK) 648 | (bind ?self:SafePaths (create$ ?self:SafePaths ?BLK))) 649 | 650 | (defmessage-handler MultiBlockContainer .AddJoin (?BLK) 651 | (bind ?self:Joins (create$ ?self:Joins ?BLK))) 652 | 653 | (defmessage-handler MultiBlockContainer .AddSplit (?BLK) 654 | (bind ?self:Splits (create$ ?self:Splits ?BLK))) 655 | ;------------------------------------------------------------------------------ 656 | (defclass Region (is-a MultiBlockContainer) 657 | (slot CanWavefrontSchedule (type SYMBOL) (allowed-values FALSE TRUE)) 658 | (slot IsSimple (type SYMBOL) (allowed-values FALSE TRUE)) 659 | (slot Depth (type NUMBER) (range 0 ?VARIABLE)) 660 | (slot IsTopLevelRegion (type SYMBOL) (allowed-values FALSE TRUE))) 661 | ;------------------------------------------------------------------------------ 662 | ; BasicBlock.clp - A CLIPS wrapper for the LLVM type 663 | (defclass BasicBlock (is-a Diplomat LLVMValue List) 664 | (multislot UnlinkedInstructions (visibility public)) 665 | (multislot Predecessors) 666 | (multislot Successors)) 667 | ;(multislot ProducingBlocks) 668 | ;(multislot ConsumingBlocks)) 669 | ;(multislot InvariantOperands) 670 | ;(multislot VariantOperands)) 671 | 672 | (defmessage-handler BasicBlock .IsSplitBlock () 673 | "Checks to see if this block is a split block. Meaning it has more than one 674 | successor" 675 | (> (length ?self:Successors) 1)) 676 | 677 | (defmessage-handler BasicBlock .IsJoinBlock () 678 | "Checks to see if this block is a join block. Meaning it has more than one 679 | predecessor" 680 | (> (length ?self:Predecessors) 1)) 681 | 682 | (defmessage-handler BasicBlock .AddPredecessor (?p) 683 | (bind ?self:Predecessors (create$ ?self:Predecessors ?p))) 684 | 685 | (defmessage-handler BasicBlock .AddPredecessors ($?p) 686 | (bind ?self:Predecessors (create$ ?self:Predecessors ?p))) 687 | 688 | (defmessage-handler BasicBlock .AddSuccessor (?p) 689 | (bind ?self:Successors (create$ ?self:Successors ?p))) 690 | 691 | (defmessage-handler BasicBlock .AddSuccessors ($?p) 692 | (bind ?self:Successors (create$ ?self:Successors ?p))) 693 | ;------------------------------------------------------------------------------ 694 | (defclass Function (is-a MultiBlockContainer)) 695 | ;------------------------------------------------------------------------------ 696 | (defclass PointerOperandObject (is-a TaggedObject) 697 | (slot PointerOperand (type SYMBOL))) 698 | 699 | (defclass MemoryModifyingObject (is-a PointerOperandObject) 700 | (slot Alignment (type NUMBER) (range 0 ?VARIABLE)) 701 | (slot IsAtomic (type SYMBOL) (allowed-values FALSE TRUE)) 702 | (slot IsSimple (type SYMBOL) (allowed-values FALSE TRUE)) 703 | (slot IsUnordered (type SYMBOL) (allowed-values FALSE TRUE)) 704 | (slot IsVolatile (type SYMBOL) (allowed-values FALSE TRUE))) 705 | 706 | (defclass PhiNode (is-a Instruction) 707 | (slot IncomingValueCount (type NUMBER) (range 0 ?VARIABLE)) 708 | (slot HasConstantValue (type SYMBOL) (allowed-values FALSE TRUE))) 709 | 710 | (defclass CallInstruction (is-a Instruction) 711 | (slot CalledFunction (type SYMBOL)) 712 | (slot IsDereferenceablePointer (type SYMBOL) (allowed-values FALSE TRUE)) 713 | (slot HasValueHandle (type SYMBOL) (allowed-values FALSE TRUE)) 714 | (slot IsTailCall (type SYMBOL) (allowed-values FALSE TRUE)) 715 | (multislot ArgumentOperands) 716 | (slot CallingConvention (type SYMBOL)) 717 | (multislot Attributes) 718 | (slot IsNoInline (type SYMBOL) (allowed-values FALSE TRUE)) 719 | (slot CanReturnTwice (type SYMBOL) (allowed-values FALSE TRUE)) 720 | (slot DoesNotAccessMemory (type SYMBOL) (allowed-values FALSE TRUE)) 721 | (slot OnlyReadsMemory (type SYMBOL) (allowed-values FALSE TRUE)) 722 | (slot DoesNotReturn (type SYMBOL) (allowed-values FALSE TRUE)) 723 | (slot DoesNotThrow (type SYMBOL) (allowed-values FALSE TRUE)) 724 | (slot HasStructRetAttr (type SYMBOL) (allowed-values FALSE TRUE)) 725 | (slot HasByValArgument (type SYMBOL) (allowed-values FALSE TRUE)) 726 | (slot IsInlineAsm (type SYMBOL) (allowed-values FALSE TRUE))) 727 | 728 | (defclass IntrinsicInstruction (is-a CallInstruction) 729 | (slot IntrinsicID (type NUMBER))) 730 | (defclass DBGInfoIntrinsic (is-a IntrinsicInstruction)) 731 | (defclass MemoryIntrinsic (is-a IntrinsicInstruction) 732 | (slot RawDestination) 733 | (slot Length (type NUMBER) (range 0 ?VARIABLE)) 734 | (slot AlignmentConstant (type NUMBER)) 735 | (slot Alignment (type NUMBER) (range 0 ?VARIABLE)) 736 | (slot IsVolatile (type SYMBOL) (allowed-values FALSE TRUE)) 737 | (slot DestinationAddressSpace (type NUMBER) (range 0 ?VARIABLE)) 738 | (slot Destination (type SYMBOL))) 739 | 740 | (defclass BinaryOperator (is-a Instruction) 741 | (slot HasNoUnsignedWrap (type SYMBOL) (allowed-values FALSE TRUE)) 742 | (slot HasNoSignedWrap (type SYMBOL) (allowed-values FALSE TRUE)) 743 | (slot IsExact (type SYMBOL) (allowed-values FALSE TRUE))) 744 | 745 | (defclass UnaryInstruction (is-a Instruction)) 746 | (defclass AllocaInstruction (is-a UnaryInstruction) 747 | ; DO NOT UNCOMMENT THIS LINE, it is for management purposes only! 748 | ;(slot SetAlignment (name "set-alignment") (type ExternalFunction) (takes-in instance , unsigned aligned) (returns void)) 749 | (slot IsStaticAllocation (type SYMBOL) (allowed-values FALSE TRUE)) 750 | (slot Alignment (type NUMBER) (range 0 ?VARIABLE)) 751 | (slot PointerType (type SYMBOL)) ; from AllocaInst::getType 752 | (slot PointerType-Pointer (type NUMBER) (range 0 ?VARIABLE)) 753 | (slot IsArrayAllocation (type SYMBOL) (allowed-values FALSE TRUE)) 754 | (slot ArraySize (type NUMBER) (range 0 ?VARIABLE)) 755 | (slot IsStatic (type SYMBOL) (allowed-values FALSE TRUE))) 756 | 757 | (defclass CastInstruction (is-a UnaryInstruction) 758 | (slot IsIntegerCast (type SYMBOL) (allowed-values FALSE TRUE)) 759 | (slot IsLosslessCast (type SYMBOL) (allowed-values FALSE TRUE)) 760 | (slot SourceType (type SYMBOL)) 761 | (slot DestinationType (type SYMBOL))) 762 | 763 | (defclass BitCastInstruction (is-a CastInstruction)) 764 | (defclass FPExtInstruction (is-a CastInstruction)) 765 | (defclass FPToSIInstruction (is-a CastInstruction)) 766 | (defclass FPToUIInstruction (is-a CastInstruction)) 767 | (defclass FPTruncInstruction (is-a CastInstruction)) 768 | (defclass IntToPtrInstruction (is-a CastInstruction)) 769 | (defclass PtrToIntInstruction (is-a CastInstruction)) 770 | (defclass SExtInstruction (is-a CastInstruction)) 771 | 772 | (defclass LoadInstruction (is-a UnaryInstruction MemoryModifyingObject) 773 | (slot PointerAddressSpace (type NUMBER) (range 0 ?VARIABLE))) 774 | ;getOrdering() is for fences...fuck that..for now 775 | ;getSynchScope() is another interesting one...no dice 776 | 777 | (defclass VAArgInstruction (is-a UnaryInstruction PointerOperandObject)) 778 | (defclass CompareInstruction (is-a Instruction) 779 | (slot SignedPredicate) 780 | (slot UnsignedPredicate) 781 | (slot IsFPPredicate (type SYMBOL) (allowed-values FALSE TRUE)) 782 | (slot IsIntPredicate (type SYMBOL) (allowed-values FALSE TRUE)) 783 | (slot IsRelational (type SYMBOL) (allowed-values FALSE TRUE)) 784 | (slot Predicate (type NUMBER)) 785 | (slot InversePredicate (type NUMBER)) 786 | (slot SwappedPredicate (type NUMBER)) 787 | (slot Opcode (type NUMBER)) 788 | (slot IsEquality (type SYMBOL) (allowed-values FALSE TRUE)) 789 | (slot IsSigned (type SYMBOL) (allowed-values FALSE TRUE)) 790 | (slot IsUnsigned (type SYMBOL) (allowed-values FALSE TRUE)) 791 | (slot IsTrueWhenEqual (type SYMBOL) (allowed-values FALSE TRUE)) 792 | (slot IsFalseWhenEqual (type SYMBOL) (allowed-values FALSE TRUE))) 793 | (defclass FloatingPointCompareInstruction (is-a CompareInstruction)) 794 | 795 | (defclass IntegerCompareInstruction (is-a CompareInstruction)) 796 | (defclass TerminatorInstruction (is-a Instruction) 797 | (multislot Successors)) 798 | (defmessage-handler TerminatorInstruction .AddSuccessor (?succ) 799 | (bind ?self:Successors (create$ ?self:Successors ?succ))) 800 | 801 | (defclass BranchInstruction (is-a TerminatorInstruction) 802 | (slot IsUnconditional (type SYMBOL) (allowed-values FALSE TRUE)) 803 | (slot IsConditional (type SYMBOL) (allowed-values FALSE TRUE)) 804 | (slot Condition) 805 | ;(slot SwapSuccessors (type EXTERNAL_FUNCTION)) 806 | ) 807 | 808 | (defclass IndirectBranchInstruction (is-a TerminatorInstruction) 809 | (slot Address (type NUMBER) (range 0 ?VARIABLE))) 810 | ;We store the destinations within the destination registers 811 | (defclass InvokeInstruction (is-a TerminatorInstruction) 812 | (multislot Arguments) 813 | (slot CalledFunction) 814 | (slot NormalDestination) 815 | (slot UnwindDestination) 816 | (slot IsNoInline (type SYMBOL) (allowed-values FALSE TRUE)) 817 | (slot OnlyReadsMemory (type SYMBOL) (allowed-values FALSE TRUE)) 818 | (slot DoesNotReturn (type SYMBOL) (allowed-values FALSE TRUE)) 819 | (slot DoesNotThrow (type SYMBOL) (allowed-values FALSE TRUE)) 820 | (slot HasStructRetAttr (type SYMBOL) (allowed-values FALSE TRUE)) 821 | (slot HasByValArgument (type SYMBOL) (allowed-values FALSE TRUE))) 822 | ;We don't need to know what function is being called 823 | (defmessage-handler InvokeInstruction .AddArgument (?arg) 824 | (bind ?self:Arguments (create$ ?self:Arguments ?arg))) 825 | 826 | (defmessage-handler InvokeInstruction .AddArguments ($?arg) 827 | (bind ?self:Arguments (create$ ?self:Arguments ?arg))) 828 | 829 | (defclass ResumeInstruction (is-a TerminatorInstruction) 830 | (slot Value (type SYMBOL))) 831 | (defclass ReturnInstruction (is-a TerminatorInstruction) 832 | (slot ReturnValue (type SYMBOL))) 833 | (defclass SwitchEntry (is-a TaggedObject) 834 | (slot Index (type NUMBER)) 835 | (slot Target (allowed-classes BasicBlock InteropObject SYMBOL))) 836 | (defclass SwitchInstruction (is-a TerminatorInstruction) 837 | (slot Condition (type SYMBOL)) 838 | (slot DefaultDestination (allowed-classes BasicBlock InteropObject SYMBOL)) 839 | (multislot Cases)) 840 | (defclass UnreachableInstruction (is-a TerminatorInstruction)) 841 | (defclass GetElementPointerInstruction (is-a Instruction PointerOperandObject) 842 | (slot PointerAddressSpace (type NUMBER) (range 0 ?VARIABLE)) 843 | (slot NumIndices (type NUMBER) (range 0 ?VARIABLE)) 844 | (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE)) 845 | (slot HasAllZeroIndices (type SYMBOL) (allowed-values FALSE TRUE)) 846 | (slot HasAllConstantIndices (type SYMBOL) (allowed-values FALSE TRUE)) 847 | (slot IsInBounds (type SYMBOL) (allowed-values FALSE TRUE))) 848 | (defclass AtomicCompareExchangeInstruction (is-a Instruction PointerOperandObject) 849 | (slot IsVolatile (type SYMBOL) (allowed-values FALSE TRUE)) 850 | (slot CompareOperand (type SYMBOL)) 851 | (slot NewValOperand (type SYMBOL)) 852 | (slot PointerAddressSpace (type NUMBER) (range 0 ?VARIABLE))) 853 | (defclass AtomicRMWInstruction (is-a Instruction PointerOperandObject) 854 | (slot Operation (type SYMBOL)) 855 | (slot IsVolatile (type SYMBOL) (allowed-values FALSE TRUE)) 856 | (slot ValueOperand (type SYMBOL))) 857 | 858 | (defclass LandingPadInstruction (is-a Instruction) 859 | (slot PersonalityFunction (type SYMBOL)) 860 | (slot IsCleanup (type SYMBOL) (allowed-values FALSE TRUE)) 861 | (multislot Clauses) 862 | (slot IsCatch (type SYMBOL) (allowed-values FALSE TRUE)) 863 | (slot IsFilter (type SYMBOL) (allowed-values FALSE TRUE))) 864 | (defclass SelectInstruction (is-a Instruction) 865 | (slot Condition (type SYMBOL)) 866 | (slot TrueValue (type SYMBOL)) 867 | (slot FalseValue (type SYMBOL))) 868 | (defclass ShuffleVectorInstruction (is-a Instruction) 869 | (slot Mask (type NUMBER)) 870 | (multislot ShuffleMask (type NUMBER) (cardinality 0 16))) 871 | (defclass StoreInstruction (is-a Instruction MemoryModifyingObject) 872 | (slot ValueOperand (type SYMBOL))) 873 | ;This is one of those instructions that have to be done inside C++ 874 | ; I'm not wasting my time pulling in the entire contents of these types 875 | (defclass ExtractElementInstruction (is-a Instruction)) 876 | (defclass InsertElementInstruction (is-a Instruction)) 877 | (defclass InsertValueInstruction (is-a Instruction)) 878 | (defclass FenceInstruction (is-a Instruction)) 879 | (defclass ExtractValueInstruction (is-a UnaryInstruction) 880 | (multislot Indices) 881 | (slot AggregateOperand)) 882 | ;------------------------------------------------------------------------------ 883 | (defclass LLVMOperator (is-a LLVMUser) 884 | (slot Opcode (type NUMBER) (range 0 ?VARIABLE))) 885 | (defclass FPMathOperator (is-a LLVMOperator) 886 | (slot FPAccuracy (type FLOAT))) 887 | (defclass OverflowingBinaryOperator (is-a LLVMOperator) 888 | (slot HasNoUnsignedWrap (type SYMBOL) (allowed-values FALSE TRUE)) 889 | (slot HasNoSignedWrap (type SYMBOL) (allowed-values FALSE TRUE))) 890 | (defclass PossiblyExactOperator (is-a LLVMOperator) 891 | (slot IsExact (type SYMBOL) (allowed-values FALSE TRUE))) 892 | ;------------------------------------------------------------------------------ 893 | (defclass Loop (is-a Region) 894 | (slot BackEdgeCount (type NUMBER) (range 0 ?VARIABLE)) 895 | (multislot BackEdges) 896 | (multislot ExitBlocks) 897 | (slot HeaderBlock) 898 | (slot LatchBlock) 899 | (slot LoopPreheader) 900 | (slot LoopPredecessor)) 901 | 902 | (defmessage-handler Loop .AddExitBlocks ($?exits) 903 | (bind ?self:ExitBlocks (create$ ?self:ExitBlocks ?exits))) 904 | 905 | (defmessage-handler Loop .AddBackEdge (?BLK) 906 | (bind ?self:BackEdges (create$ ?self:BackEdges ?BLK))) 907 | 908 | ;------------------------------------------------------------------------------ 909 | (defclass Replacement (is-a TaggedObject) 910 | (slot Target) 911 | (multislot With)) 912 | ;------------------------------------------------------------------------------ 913 | ; This is a template instead of a class and is meant to provide fix up hints 914 | ; with respect to CFG modification 915 | ;------------------------------------------------------------------------------ 916 | 917 | (deftemplate ControlModification 918 | (slot ModificationType (type SYMBOL) (allowed-values Relinquish Transfer)) 919 | (slot From (type SYMBOL)) 920 | (slot To (type SYMBOL)) 921 | (multislot Subject (type SYMBOL))) 922 | ;------------------------------------------------------------------------------ 923 | (defclass CompensationPathVector (is-a TaggedObject) 924 | (multislot Failures (visibility public)) 925 | (multislot Paths (visibility public)) 926 | (multislot ScheduleTargets (visibility public)) 927 | (multislot Slices (visibility public)) 928 | (multislot Aliases (visibility public)) 929 | (slot OriginalBlock (visibility public))) 930 | ;------------------------------------------------------------------------------ 931 | (defclass OwnershipDeterminant (is-a TaggedObject) 932 | (multislot Claims) 933 | (multislot IndirectClaims) 934 | (multislot PotentialChildren)) 935 | --------------------------------------------------------------------------------