bool HasAllSet(const llvm::Value* value) { const llvm::Constant* c = llvm::dyn_cast<llvm::Constant>(value); if (! c) return false; if (IsScalar(c->getType())) { return GetConstantInt(c) == -1; } else { assert(llvm::isa<llvm::ConstantDataVector>(c) || llvm::isa<llvm::ConstantVector>(c)); for (unsigned int op = 0; op < GetComponentCount(c); ++op) { if (GetConstantInt(c->getAggregateElement(op)) != -1) return false; } return true; } }
static unsigned BuildNativeDeclaration( D3D11_SO_DECLARATION_ENTRY nativeDeclaration[], unsigned nativeDeclarationCount, const GeometryShader::StreamOutputInitializers& soInitializers) { auto finalCount = std::min(nativeDeclarationCount, soInitializers._outputElementCount); for (unsigned c=0; c<finalCount; ++c) { auto& ele = soInitializers._outputElements[c]; nativeDeclaration[c].Stream = 0; nativeDeclaration[c].SemanticName = ele._semanticName.c_str(); nativeDeclaration[c].SemanticIndex = ele._semanticIndex; nativeDeclaration[c].StartComponent = 0; nativeDeclaration[c].ComponentCount = (BYTE)GetComponentCount(GetComponents(ele._nativeFormat)); // hack -- treat "R16G16B16A16_FLOAT" as a 3 dimensional vector if (ele._nativeFormat == NativeFormat::Enum::R16G16B16A16_FLOAT) nativeDeclaration[c].ComponentCount = 3; nativeDeclaration[c].OutputSlot = (BYTE)ele._inputSlot; assert(nativeDeclaration[c].OutputSlot < soInitializers._outputBufferCount); } return finalCount; }
{ AddNewSubrecord(SR_NAME_COCT); if (m_pComponentCount == NULL) return; m_pComponentCount->InitializeNew(); } m_pComponentCount->SetValue(CountSubrecords(SR_NAME_CNTO)); } /*=========================================================================== * * Begin CSrCobjRecord Get Field Methods * *=========================================================================*/ DEFINE_SRGETFIELD(CSrCobjRecord::GetFieldComponentCount, String.Format("%u", GetComponentCount())) DEFINE_SRGETFIELD(CSrCobjRecord::GetFieldResultCount, String.Format("%u",(dword)GetResultCount())) DEFINE_SRGETFIELD(CSrCobjRecord::GetFieldResultItem, String = GetResultItem()) DEFINE_SRGETFIELD(CSrCobjRecord::GetFieldStation, String = GetStation()) /*=========================================================================== * End of CSrCobjRecord Get Field Methods *=========================================================================*/ /*=========================================================================== * * Begin CSrCobjRecord Compare Field Methods * *=========================================================================*/ DEFINE_SRCOMPFIELDDWORD(CSrCobjRecord, CompareFieldComponentCount, GetComponentCount) DEFINE_SRCOMPFIELDDWORD(CSrCobjRecord, CompareFieldResultCount, GetResultCount)
bool IsPerComponentOp(const llvm::Instruction* inst) { if (const llvm::IntrinsicInst* intr = llvm::dyn_cast<const llvm::IntrinsicInst>(inst)) return IsPerComponentOp(intr); if (inst->isTerminator()) return false; switch (inst->getOpcode()) { // Cast ops are only per-component if they cast back to the same vector // width case llvm::Instruction::Trunc: case llvm::Instruction::ZExt: case llvm::Instruction::SExt: case llvm::Instruction::FPToUI: case llvm::Instruction::FPToSI: case llvm::Instruction::UIToFP: case llvm::Instruction::SIToFP: case llvm::Instruction::FPTrunc: case llvm::Instruction::FPExt: case llvm::Instruction::PtrToInt: case llvm::Instruction::IntToPtr: case llvm::Instruction::BitCast: return GetComponentCount(inst->getOperand(0)) == GetComponentCount(inst); // Vector ops case llvm::Instruction::InsertElement: case llvm::Instruction::ExtractElement: case llvm::Instruction::ShuffleVector: // Ways of accessing/loading/storing vectors case llvm::Instruction::ExtractValue: case llvm::Instruction::InsertValue: // Memory ops case llvm::Instruction::Alloca: case llvm::Instruction::Load: case llvm::Instruction::Store: case llvm::Instruction::GetElementPtr: // Phis are a little special. We consider them not to be per-component // because the mechanism of choice is a single value (what path we took to // get here), and doesn't choose per-component (as select would). The caller // should know to handle phis specially case llvm::Instruction::PHI: // Call insts, conservatively are no per-component case llvm::Instruction::Call: // Misc // case llvm::Instruction::LandingPad: --- 3.0 case llvm::Instruction::VAArg: return false; } // end of switch (inst->getOpcode()) return true; }