gpu_decoder.hh revision 11308:7d8836fd043d
19919Ssteve.reinhardt@amd.com/*
29919Ssteve.reinhardt@amd.com * Copyright (c) 2015 Advanced Micro Devices, Inc.
39919Ssteve.reinhardt@amd.com * All rights reserved.
49919Ssteve.reinhardt@amd.com *
59919Ssteve.reinhardt@amd.com * For use for simulation and test purposes only
69919Ssteve.reinhardt@amd.com *
79919Ssteve.reinhardt@amd.com * Redistribution and use in source and binary forms, with or without
89919Ssteve.reinhardt@amd.com * modification, are permitted provided that the following conditions are met:
99919Ssteve.reinhardt@amd.com *
109919Ssteve.reinhardt@amd.com * 1. Redistributions of source code must retain the above copyright notice,
119919Ssteve.reinhardt@amd.com * this list of conditions and the following disclaimer.
129919Ssteve.reinhardt@amd.com *
139919Ssteve.reinhardt@amd.com * 2. Redistributions in binary form must reproduce the above copyright notice,
149919Ssteve.reinhardt@amd.com * this list of conditions and the following disclaimer in the documentation
159919Ssteve.reinhardt@amd.com * and/or other materials provided with the distribution.
169919Ssteve.reinhardt@amd.com *
179919Ssteve.reinhardt@amd.com * 3. Neither the name of the copyright holder nor the names of its contributors
189919Ssteve.reinhardt@amd.com * may be used to endorse or promote products derived from this software
199919Ssteve.reinhardt@amd.com * without specific prior written permission.
209919Ssteve.reinhardt@amd.com *
219919Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
229919Ssteve.reinhardt@amd.com * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
239919Ssteve.reinhardt@amd.com * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
249919Ssteve.reinhardt@amd.com * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
259919Ssteve.reinhardt@amd.com * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
269919Ssteve.reinhardt@amd.com * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
279919Ssteve.reinhardt@amd.com * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
289919Ssteve.reinhardt@amd.com * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
299919Ssteve.reinhardt@amd.com * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
309919Ssteve.reinhardt@amd.com * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
319919Ssteve.reinhardt@amd.com * POSSIBILITY OF SUCH DAMAGE.
329919Ssteve.reinhardt@amd.com *
339919Ssteve.reinhardt@amd.com * Author: Anthony Gutierrez
349919Ssteve.reinhardt@amd.com */
359919Ssteve.reinhardt@amd.com
3611793Sbrandon.potter@amd.com#ifndef __ARCH_HSAIL_GPU_DECODER_HH__
379919Ssteve.reinhardt@amd.com#define __ARCH_HSAIL_GPU_DECODER_HH__
389919Ssteve.reinhardt@amd.com
399920Syasuko.eckert@amd.com#include <vector>
4010935Snilay@cs.wisc.edu
419919Ssteve.reinhardt@amd.com#include "arch/hsail/gpu_types.hh"
429919Ssteve.reinhardt@amd.com
439920Syasuko.eckert@amd.comclass BrigObject;
4412105Snathanael.premillieu@arm.comclass GPUStaticInst;
4512105Snathanael.premillieu@arm.com
4612105Snathanael.premillieu@arm.comnamespace Brig
479920Syasuko.eckert@amd.com{
489920Syasuko.eckert@amd.com    class BrigInstBase;
4910935Snilay@cs.wisc.edu}
509919Ssteve.reinhardt@amd.com
5112105Snathanael.premillieu@arm.comnamespace HsailISA
5212105Snathanael.premillieu@arm.com{
5312105Snathanael.premillieu@arm.com    class Decoder
549920Syasuko.eckert@amd.com    {
559920Syasuko.eckert@amd.com      public:
569920Syasuko.eckert@amd.com        GPUStaticInst* decode(MachInst machInst);
579920Syasuko.eckert@amd.com
589920Syasuko.eckert@amd.com        GPUStaticInst*
599920Syasuko.eckert@amd.com        decode(RawMachInst inst)
6012105Snathanael.premillieu@arm.com        {
6112105Snathanael.premillieu@arm.com            return inst < decodedInsts.size() ? decodedInsts.at(inst) : nullptr;
6212105Snathanael.premillieu@arm.com        }
6312105Snathanael.premillieu@arm.com
6412105Snathanael.premillieu@arm.com        RawMachInst
6512105Snathanael.premillieu@arm.com        saveInst(GPUStaticInst *decodedInst)
6612105Snathanael.premillieu@arm.com        {
6712105Snathanael.premillieu@arm.com            decodedInsts.push_back(decodedInst);
6812105Snathanael.premillieu@arm.com
6912105Snathanael.premillieu@arm.com            return decodedInsts.size() - 1;
7012105Snathanael.premillieu@arm.com        }
7112105Snathanael.premillieu@arm.com
7212105Snathanael.premillieu@arm.com      private:
7312105Snathanael.premillieu@arm.com        static std::vector<GPUStaticInst*> decodedInsts;
7412105Snathanael.premillieu@arm.com    };
7512105Snathanael.premillieu@arm.com} // namespace HsailISA
7612105Snathanael.premillieu@arm.com
7712105Snathanael.premillieu@arm.com#endif // __ARCH_HSAIL_GPU_DECODER_HH__
7812105Snathanael.premillieu@arm.com