Jim Laskey | 0cf8ed6 | 2006-03-23 18:05:12 +0000 | [diff] [blame^] | 1 | //===-- InstrinsicInst.cpp - Intrinsic Instruction Wrappers -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/IntrinsicInst.h" |
| 11 | |
| 12 | #include "llvm/Constants.h" |
| 13 | #include "llvm/GlobalVariable.h" |
| 14 | |
| 15 | using namespace llvm; |
| 16 | |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | /// DbgInfoIntrinsic - This is the common base class for debug info intrinsics |
| 19 | /// |
| 20 | |
| 21 | static Value *CastOperand(Value *C) { |
| 22 | if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) |
| 23 | if (CE->getOpcode() == Instruction::Cast) |
| 24 | return CE->getOperand(0); |
| 25 | return NULL; |
| 26 | } |
| 27 | |
| 28 | Value *DbgInfoIntrinsic::StripCast(Value *C) { |
| 29 | if (Value *CO = CastOperand(C)) { |
| 30 | return StripCast(CO); |
| 31 | } else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) { |
| 32 | if (GV->hasInitializer()) |
| 33 | if (Value *CO = CastOperand(GV->getInitializer())) |
| 34 | return StripCast(CO); |
| 35 | } |
| 36 | return C; |
| 37 | } |
| 38 | |
| 39 | //===----------------------------------------------------------------------===// |
| 40 | /// DbgStopPointInst - This represents the llvm.dbg.stoppoint instruction. |
| 41 | /// |
| 42 | |
| 43 | std::string DbgStopPointInst::getFileName() const { |
| 44 | GlobalVariable *GV = cast<GlobalVariable>(getContext()); |
| 45 | ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer()); |
| 46 | return CS->getOperand(4)->getStringValue(); |
| 47 | } |
| 48 | |
| 49 | std::string DbgStopPointInst::getDirectory() const { |
| 50 | GlobalVariable *GV = cast<GlobalVariable>(getContext()); |
| 51 | ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer()); |
| 52 | return CS->getOperand(5)->getStringValue(); |
| 53 | } |
| 54 | |
| 55 | //===----------------------------------------------------------------------===// |